# Absolute value of Bose-Einstein distribution

I would like to produce a 3D plot of |n_B(z)| = (e^(2*x) - 2*e^x*cos(y) + 1)^(-1/2), where |n_B(z)| is the absolute value of the Bose-Einstein distribution n_B(z) = 1/(e^(z/T) - 1) of the complex variable z = x + i y. (I set the temperature T = 1 for simplicity.) Here's what I have so far.

\documentclass{standalone}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=$\Re(p_0)$,
ylabel=$\Im(p_0)$,
zlabel=$n_B(p_0)$,
restrict z to domain*=0:2,
tickwidth=0pt
]

surf,domain=-10:-5,y domain=-30:30,
blue!20,samples=5]
{1};

surf,domain=-5:5,y domain=-30:30,
blue!20,samples=70]
{(e^(2*x) - 2*e^x*cos(deg(y)) + 1)^(-1/2)};

surf,domain=5:10,y domain=-30:30,
blue!20,samples=5]
{0};

\end{axis}
\end{tikzpicture}
\end{document}


I increased the sample rate close to TeX's maximum capacity and tried to concentrate that sampling on the region where it actually matters by approximating the function as 0 for x >> 0 and 1 for x << 0 where it is almost constant. However, the plot still shows small artifacts around the singularities. Any suggestions on how to improve the appearance and compilation speed would be welcome!

• The "overshooting" can be prevented by adding miter limit=1 to the axis environment options. – Stefan Pinnow May 9 '17 at 17:11
• Using y domain=-10:10 should be adequate to show the cyclical nature. – John Kormylo May 9 '17 at 18:08

Just for fun:

\documentclass{standalone}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=$\Re(p_0)$,
ylabel=$\Im(p_0)$,
zlabel=$n_B(p_0)$,
miter limit=1,
tickwidth=0pt
]

surf,domain=-10:10,y domain=-10:10,
restrict z to domain*=0:1.2,
blue!20,samples=20,samples y=25]
{(e^(2*x) - 2*e^x*cos(deg(y)) + 1)^(-1/2)};

surf,domain=-2:1,y domain=-10:10,
restrict z to domain*=0:1.5,
blue!20,samples=20,samples y=50]
{(e^(2*x) - 2*e^x*cos(deg(y)) + 1)^(-1/2)};

surf,domain=-1:0.5,y domain=5.3:7.3,
restrict z to domain*=0:2,
blue!20,samples=20,samples y=20]
{(e^(2*x) - 2*e^x*cos(deg(y)) + 1)^(-1/2)};

surf,domain=-1:0.5,y domain=-1:1,
restrict z to domain*=0:2,
blue!20,samples=20,samples y=20]
{(e^(2*x) - 2*e^x*cos(deg(y)) + 1)^(-1/2)};