Essentially I want to plot a function with singularities like
$\frac{1}{(x-0.5)^2+(y-0.5)^2}\cdot \frac{1}{(x+0.5)^2+(y+0.5)^2}$
at a higher sampling rate.
I tried to avoid the singularities by capping with some value ($20$):
\begin{tikzpicture}
\begin{axis}[view={55}{45}]
\addplot3[surf, colormap/jet, samples=50, domain=-1:1] {min(1/((x-0.5)^2+(y-0.5)^2)* 1/((x+0.5)^2+(y+0.5)^2),20)};
\end{axis}
\end{tikzpicture}
Which yields
But that really does not stop TikZ/pfgplots from having to evaluate the function near its singularities, so it gets quite slow at compiling. So here is my question:
Is there a better/faster way to plot functions that contain singularities? Or do i have to precompute the data and give it to TikZ/pfgplots manually?
\pgfplotsset{compat=newest}
. This will evaluate the function in Lua which is much faster.1/max(((x-0.5)^2+(y-0.5)^2)*((x+0.5)^2+(y+0.5)^2),.05)
which has no singularity. The problem is that LaTeX is slow and you ask forsamples=50
.range3frame
is a leftover from another plot, it doesn't do anything.