是否有 \addplot3[surf] 的平面(投影)版本?

是否有 \addplot3[surf] 的平面(投影)版本?

这与“Riley、Hobson 和 Bence - 物理和工程的数学方法”中的 5.7 问题有关。

我想要显示一个 2D 投影(从 z 向下看)版本的表面,并保持颜色渐变。我还想为不同的“a”值添加一组抛物线(黑色),如问题中所示。非常感谢。

\documentclass{memoir}

% __________ AMS ________________________
  \usepackage{amsmath}
% __________ PGF TikZ ___________________
  \usepackage{pgfplots}
% \usepackage{tikz}
  \usepackage{tikz-3dplot}

% __________ Differentials _____________________________________________________
% Single
    \newcommand{\diff}{d}           % If you want an upright `d', change it here
    \newcommand{\p}[1]{\partial#1}  
% ___________________ Derivatives ______________________________________________
% 1st derivative:
    \newcommand{\dod}[2]{\dfrac{\diff{#1}}{\diff{#2}}}  % 'differential over differential'
    \newcommand{\pop}[2]{\dfrac{\p#1}{\p#2}}            % 'partial over partial'
    \newcommand{\lpop}[2]{\p#1/\p#2}            % A 'layed down' version

\setlength{\parindent}{0cm}
\begin{document}

\textbf{Problem 5.7}\par
\centering
\textbf{The Chain Rule and Stationary Points}\\[3mm]
\flushleft
  \fbox{\parbox{4.25in}{
    The function $G(t)$ is defined by
    $$ G(t) = F(x,y) = x^2 + y^2 + 3xy $$
    where $x(t) = at^2$ and $y(t) = 2at$. Use the chain rule to find the values of $(x,y)$ at which $G(t)$ has stationary values as a function of $t$. Do any of them correspond to the stationary points of $F(x,y)$ as a function of $x$ and $y$?
    }}
\flushleft

  \vspace{3mm}
  \noindent\emph{Solution:}\\[1mm]
  (To be terse, the derivation has been omitted.)\\[2mm]
  The Stationary points occur at $\lpop Ft = 0$, in which case
  \[ 2a^2t(2t + 1)(t + 4) = 0 \]
  So,
  \[ t\in \{ -4,\ -1/2,\ 0 \} \]
  This corresponds to the stationary points
  \[ (16a,\ -8a)\ ,\quad (a/4,\ -a)\ ,\quad (0,\ 0) \]
  To answer the second part of the question, we differentiate $F(x,y)$ with respect to $x$, and $y$, and set these to zero;
  \[ \pop Fx = 2x + 3y = 0 \]
  \[ \pop Fy = 3x + 2y = 0 \]
  The only solution is $(0,\ 0)$.

\centering
\begin{figure}
  \tdplotsetmaincoords{0}{0}
  \begin{tikzpicture}[tdplot_main_coords,scale=1.5,rotate=0]
    \begin{axis}[domain=-6:6,y domain=-6:6]
      \addplot3[surf] {x^2 + y^2 + 3*x*y};
    \end{axis}
  \end{tikzpicture}
  \caption{$z = x^2 + y^2 + 3xy$}
\end{figure}
\flushleft

The other two solutions for $t$, are the stationary points for the parabolic sheet (not shown) $(at^2, 2at, t)$ that intersects with the surface shown. There is also the two-dimensional version realized by looking down from $z$ (i.e. the projection onto the $z$-plane). The blue to orange colors could then be interpreted, for example, as a scalar field for temperature.

\end{document}

答案1

对于标题中的问题,大家可以补充view={0}{90}一下axis选项。

要绘制 f(x) = 2*sqrt(a*x),请执行类似 的操作\addplot [black] {2*sqrt(2*x)};,如果 a=2。您需要为抛物线的负部分绘制第二个图。

在下面的例子中我使用了这样的循环:

  \pgfplotsinvokeforeach{0.25,1}{% values of a, represented by #1 in the loop code
      \addplot [black, samples at={0,0.01,...,1,1.6}] {2*sqrt(#1*x)} node[above left] {$a=#1$};
      \addplot [black, samples at={0,0.01,...,6}] {-2*sqrt(#1*x)};
      }

这些samples at东西是为了让剧情更加流畅。

其他一些变化:

  • 正如 Christian 在评论中提到的那样,不要使用$$ ... $$它来显示数学,最好坚持使用\[ ... \]。(参见为什么\[ … \]优于$$
  • 我添加了\nonzeroparskip序言,删除了所有内容\\[<some length>],并添加了一些段落分隔符(空行)。
  • 我没有使用各种\centering ... \flushleft,而是在环境中添加了标题center,然后将其移动\centering里面环境figure
  • 我把这些tikz-3dplot东西删掉了,你不用它。
  • 我删除了并在选项中scale=1.5添加了。width=...axis

在此处输入图片描述

\documentclass{memoir}

% __________ AMS ________________________
  \usepackage{amsmath}
% __________ PGF TikZ ___________________
  \usepackage{pgfplots}

% __________ Differentials _____________________________________________________
% Single
    \newcommand{\diff}{d}           % If you want an upright `d', change it here
    \newcommand{\p}[1]{\partial#1}  
% ___________________ Derivatives ______________________________________________
% 1st derivative:
    \newcommand{\dod}[2]{\dfrac{\diff{#1}}{\diff{#2}}}  % 'differential over differential'
    \newcommand{\pop}[2]{\dfrac{\p#1}{\p#2}}            % 'partial over partial'
    \newcommand{\lpop}[2]{\p#1/\p#2}            % A 'layed down' version

\setlength{\parindent}{0pt}
\nonzeroparskip % <--- added
\begin{document}

\textbf{Problem 5.7}
\begin{center}
\textbf{The Chain Rule and Stationary Points}
\end{center}
  \fbox{\parbox{4.25in}{
    The function $G(t)$ is defined by
    \[ G(t) = F(x,y) = x^2 + y^2 + 3xy \]
    where $x(t) = at^2$ and $y(t) = 2at$. Use the chain rule to find the values of $(x,y)$ at which $G(t)$ has stationary values as a function of $t$. Do any of them correspond to the stationary points of $F(x,y)$ as a function of $x$ and $y$?
    }}

  \medskip
  \emph{Solution:}

  (To be terse, the derivation has been omitted.)

  The Stationary points occur at $\lpop Ft = 0$, in which case
  \[ 2a^2t(2t + 1)(t + 4) = 0 \]
  So,
  \[ t\in \{ -4,\ -1/2,\ 0 \} \]
  This corresponds to the stationary points
  \[ (16a,\ -8a)\ ,\quad (a/4,\ -a)\ ,\quad (0,\ 0) \]
  To answer the second part of the question, we differentiate $F(x,y)$ with respect to $x$, and $y$, and set these to zero;
  \begin{align*}
   \pop Fx &= 2x + 3y = 0 \\
   \pop Fy &= 3x + 2y = 0
  \end{align*}
  The only solution is $(0,\ 0)$.

\begin{figure}
  \centering
  \begin{tikzpicture}
    \begin{axis}[
        width=0.8\linewidth, % <-- instead of scale
        domain=-6:6,
        y domain=-6:6,
        view={0}{90}
        ]
      \addplot3[surf] {x^2 + y^2 + 3*x*y};

      \pgfplotsinvokeforeach{0.25,1}{% values of a, represented by #1 in the loop code
          \addplot [black, smooth, samples at={0,0.01,...,6}] {2*sqrt(#1*x)} node[above left] {$a=#1$};
          \addplot [black, smooth, samples at={0,0.01,...,6}] {-2*sqrt(#1*x)};
          }

    \end{axis}
  \end{tikzpicture}
  \caption{$z = x^2 + y^2 + 3xy$}
\end{figure}

The other two solutions for $t$, are the stationary points for the parabolic sheet (not shown) $(at^2, 2at, t)$ that intersects with the surface shown. There is also the two-dimensional version realized by looking down from $z$ (i.e. the projection onto the $z$-plane). The blue to orange colors could then be interpreted, for example, as a scalar field for temperature.

\end{document}

相关内容