0

Recently, I tried graphing the function z = xy + e^(-xy) using tikzpicture and \addplot3. But for some reason, the graph is bugging out as its thinking that z = 0 for all values (except a few at the edge):

\begin{tikzpicture}
\begin{axis}[
    view = {30}{30},
    xlabel  = {$x$},
    ylabel = {$y$},
    zlabel = {$z$},
    axis on top,
    axis lines = center,
    zmin = 0
]
\addplot3[surf]{x*y + e^(-x*y)};
\end{axis}
\end{tikzpicture}

This is resulting in a graph that looks like:

enter image description here

But if you graph it somewhere else like GeoGebra (or any other 3d plotting tool) or try to draw it by hand, the value should be 1 along the x and y axis and then increase as you go outward. Is there any reason this is happening? (P.S. if I try to set a zmax value I get a "missing number" error probably because the equation I'm graphing increases rapidly and even at (-5,5) z ~ 7.2e+10)

Sid
  • 1
  • The output looks correct to me. That is exactly what this function looks like. Did you maybe forget to put a z cutoff? Check out the restrict z to domain key. – Henri Menke Jun 24 '20 at 04:44
  • Is it? When I looked at the actual graph it looks like this – Sid Jun 24 '20 at 06:20
  • Yes, it does look like this. Here is a picture of the function plotted with the tool gnuplot: https://i.stack.imgur.com/M9QQz.png – Henri Menke Jun 24 '20 at 06:49
  • It looks like that on gnullot, but the actual graph looks quite different when you graph it on online tools like geogebra and when you draw the graph manually. Using restrict z to domain seemed to make the graph appear correctly – Sid Jun 25 '20 at 05:19

0 Answers0