%24%20%E3%82%92%E6%8F%8F%E3%81%8F%E6%96%B9%E6%B3%95.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]
、pgfplots
影響を受ける領域には何もプロットされなくなります。
私がetcで行ったように、オプションに手動で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}