I'm trying to plot this function
which should render as something like this (as generated by CalcPlot3D)
Problem is, I can't get pgfplots to generate something similar even with a pretty big samples
number such as 150. Also, compilation time becomes exceedingly long, which would be a small problem, given I'm externalizing graphs, but still the result is suboptimal.
As you can see in the image, my output is fractured near z=0 (where the function is a circumference), but that is the most important part of the plot for my exposition, since I have to point out that this function has infinite absolute maxima points.
Here is my current code (disclaimer: don't run it unless you're in for 5 minutes of 100% cpu usage)
\documentclass{book}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=$x$, ylabel=$y$,
]
\addplot3[surf, domain =-2:2, domain y=-2:2, unbounded coords=jump, samples=150]
{ x^2 + y^2 >= 1 ? -sqrt(x^2+y^2-1) : NaN };
\end{axis}
\end{tikzpicture}
\end{document}
Do you guys have a tip on how to plot this function correctly, other than embedding a pre-rendered image?