2

It's easy show that f(x,y)=2-x^2-y^2 has a maximun value in (x,y)=(0,0), I need a plot show this result. I tried this:

\documentclass{article}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}

  \begin{axis}[domain=-2:2,y domain=-4:4]

    \addplot3[surf] {2-x^2-y^2)};

  \end{axis}

\end{tikzpicture}

\end{document}

But it was horrible and $z$ axis don't show value 2 . Can you help me?

1 Answer 1

5

If you use the correct viewing angle, you can see that the max z is in fact at 2.

\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{tikz-3dplot}

\begin{document}

\begin{tikzpicture}
  \begin{axis}[domain=-2:2,y domain=-4:4, view={60}{0},
  extra z ticks={2}]
    \addplot3[surf] {2-x*x-y*y)};
  \end{axis}
\end{tikzpicture}
\end{document}

demo

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.