%24.png)
我嘗試了但沒用
\def\Xmin{-2} \def\Xmax{2}
\def\Ymin{-2} \def\Ymax{2}
\def\Xunit{1.5cm} \def\Yunit{1.5cm}
\def\Xleg{\small \sffamily $x$} % légende en abscisse
\def\Yleg{\small \sffamily $y$} % légende en ordonnées
\begin{tikzpicture}[x=\Xunit,y=\Yunit]
\draw[>= latex,->,thick](\Xmin,1)--(\Xmax,1);
\draw[>= latex,->,thick](1,\Ymin)--(1,\Ymax);
\draw [domain=\Xmin:\Xmax,thick,red] plot (\x,{(ln(\x+(sqrt{((\x)^2}-1)))});
\end{tikzpicture}
答案1
不要手動完成 LaTeX 可以為您做的事情,使用pgfplots
它來添加更好的繪圖功能,包括自動軸
請注意,如果沒有pgfplots
是可能,但它沒有保存內建檢查。例如,在建議的域 [-2,2] 中,函數x+sqrt{x^2-1}
切入未定義的負數ln
。我們會得到錯誤
! Package PGF Math Error: I cannot calculate the logarithm of -0.26794
但pfdplots
有內建的檢查,這樣事情就不會爆炸,所以在這裡給它一個[-2,2]
will work 的域,pgfplots
只是不會在受影響的區域繪製任何東西。
您可能需要像我一樣在選項中手動新增ymin
和等。ymax
axis
xmin
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
unbounded coords=jump,
domain=-2:2,
xmin=-2,
xmax=2,
]
\addplot[red,smooth] {ln(\x+(sqrt((\x)^2-1)))};
\end{axis}
\end{tikzpicture}
\end{document}
這是一個顯示原始函數和內部函數的行為的範例。
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
unbounded coords=jump,
domain=-2:2,
axis lines=middle,
legend style={at={(-0.015,0.95)},anchor=north west,cells={anchor=west}},
]
\addplot[red,smooth,samples=1001] {ln(\x+(sqrt((\x)^2-1)))};
\addlegendentry{$\ln(x+\sqrt{x^2-1})$}
\addplot[blue,smooth,samples=1001] {x+sqrt((\x)^2-1)};
\addlegendentry{$x+\sqrt{x^2-1}$}
\end{axis}
\end{tikzpicture}
\end{document}