1

I have tried graphing it with the parametric notation (i.e. ({x},{y},{sort(x^2-y^2)}) and as seen on my code below but nothing renders the image shown on graphing calculators.

\begin{tikzpicture}[scale=1.5]
\begin{axis}[
grid=major,
3d box=complete,
enlargelimits=false,
colormap/cool,
xlabel=$x$,
ylabel=$y$,
zlabel=$z$,
zlabel style = {sloped like x axis}
]
\addplot3 [
surf,
shader=faceted,
samples=50,
z buffer=sort,
]  {sqrt((x)^2-(y)^2)};

\end{axis}
\end{tikzpicture}
2

You did almost everything right, pgfplots is just not very good at taking the square root of a negative number. So if you adjust the domains a bit you get

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\begin{axis}[
grid=major,
3d box=complete,
enlargelimits=false,
colormap/cool,
xlabel=$x$,
ylabel=$y$,
zlabel=$z$,
zlabel style = {sloped like x axis}
]
\addplot3 [domain=2:4,domain y=-2:2,
surf,
shader=faceted,
samples=50,
z buffer=sort,
]  {sqrt(x^2-y^2)};

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

enter image description here

As for your request in the comments, one can write the function as sqrt(u*v), where u=x+y and v=x-y. Then x=(u+v)/2 and y=(u-v)/2. Since the variables are just placeholders in a parametric plot, we can rename u and v to x and y, respectively, and arrive at

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\begin{axis}[xmax=2,xmin=-2,
grid=major,
3d box=complete,
enlargelimits=false,
colormap/cool,
xlabel=$x$,
ylabel=$y$,
zlabel=$z$,
zlabel style = {sloped like x axis}
]
\addplot3 [domain=0:4,domain y=0:4,
surf,
shader=faceted,
samples=50,
z buffer=sort,
] ({(x+y)/2},{(x-y)/2},{sqrt(x*y)});
\addplot3 [domain=0:4,domain y=0:4,
surf,
shader=faceted,
samples=50,
z buffer=sort,
] ({-(x+y)/2},{-(x-y)/2},{sqrt(x*y)});

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

enter image description here

  • Thanks though that fixed most of it. Though yesterday I forgot to post the image of how I would like my graph to look like. How can I make the graph look more like this? – Daniel Hernández Feb 28 at 13:34
  • @DanielHernández I added a graph of this sort. – marmot Feb 28 at 15:22
  • ©marmot Thanks! That's what I needed. Pgfplots still is kind of confusing for me. – Daniel Hernández Feb 28 at 17:52
  • @DanielHernández You are welcome! (The issue here is more a parametrization question than a pgfplots question, I think. But you're right, pgfplots is a nontrivial packages with lots of functionality that one keeps discovering.) – marmot Feb 28 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.