我一直在尝试绘制以下由 ln(2x²-1)/(x²-1) 定义的函数,该函数应该产生一个对称图。绘制图形右侧时,我什么也没做,只是沿 y 轴反射域,但结果不是对称图。发生了什么?
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[gray!20] (-2.9,-2.9) grid (2.9,2.9);
\draw[-latex,thick] (-3,0)--(3,0) node[right]{$x$};
\draw[-latex,thick] (0,-3)--(0,3) node[above]{$y$};
\foreach \x in {-2,-1,1,2}
\draw (\x,.1)--(\x,-.1) node[below] {\x};
\foreach \y in {-2,-1,1,2}
\draw (-.1,\y)--(.1,\y) node[right] {\y};
\draw[thick,blue!50!black, domain=-3:-1.15,smooth,variable=\x] plot ({\x},{(ln(2\x*\x-1))/(\x*\x-1)});
%%% Something is wrong with the following plot %%%
\draw[thick,blue!50!black, domain=1.15:3,smooth,variable=\x] plot ({\x},{(ln(2\x*\x-1))/(\x*\x-1)});
\end{tikzpicture}
\end{document}
答案1
因此,您只需使用显式乘法来避免数字的“错误”扩展。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[gray!20] (-2.9,-2.9) grid (2.9,2.9);
\draw[-latex,thick] (-3,0)--(3,0) node[right]{$x$};
\draw[-latex,thick] (0,-3)--(0,3) node[above]{$y$};
\foreach \x in {-2,-1,1,2}
\draw (\x,.1)--(\x,-.1) node[below] {\x};
\foreach \y in {-2,-1,1,2}
\draw (-.1,\y)--(.1,\y) node[right] {\y};
\draw[thick,blue!50!black, domain=-3:-1.15,smooth,variable=\x] plot ({\x},{(ln(2*\x*\x-1))/(\x*\x-1)});
%%% Something is wrong with the following plot %%%
\draw[thick,blue!50!black, domain=1.15:3,smooth,variable=\x] plot ({\x},{(ln(2*\x*\x-1))/(\x*\x-1)});
\end{tikzpicture}
\end{document}