我嘗試使用參數符號(即({x},{y},{sort(x^2-y^2)})繪製它,如下面的程式碼所示,但沒有任何內容呈現圖形計算器上顯示的圖像。
\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}
答案1
你幾乎做對了所有事情,pgfplots
但不太擅長取負數的平方根。所以如果你稍微調整一下網域,你就會得到
\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}
至於你在評論中的要求,可以將函數寫為sqrt(u*v)
, whereu=x+y
和v=x-y
。然後x=(u+v)/2
和y=(u-v)/2
。由於變數只是參數圖中的佔位符,因此我們可以分別將u
和重新命名v
為x
和y
,並得出
\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}