答案1
绘制已知函数 的反函数不需要任何特殊的东西f(x)
。要理解这一点,回想一下 的图f(x)
可以看作 的参数图
(x,f(x))
立即致电x=f^{-1}(t)
。那么这块地将
(f^{-1}(t),t) .
由此可见,一个阴谋
(f(t),t)
是相同的
(t,f^{-1}(t))
当然,我们必须适当调整域。因此,为了绘制arctan(x)
(该函数的 pgf 名称是atan
,请参阅JairoAraujo 的评论,或者atan2
,处理象限),我们可以绘制
(tan(t),t)
以及arccot
(cot(t),t) .
本 MWE 对此进行了说明
\documentclass[tikz,border=3mm]{standalone}
\usepackage{amsmath}
\DeclareMathOperator{\arccot}{arccot}
\begin{document}
\begin{tikzpicture}[trig format=rad,samples=101]
\draw[blue,thick] plot[variable=\t,domain=-pi/2+0.1:pi/2-0.1] ({tan(\t)},\t);
\draw[red,dashed,thick] plot[variable=\t,domain=-10:10] (\t,{atan(\t)});
\path (8,pi/2) node[above]{$y=\arctan(x)$};
\draw plot[variable=\t,domain=-pi/2+0.1:-0.1] ({cot(\t)},\t);
\draw plot[variable=\t,domain=0.1:pi/2-0.1] ({cot(\t)},\t);
\path (8,0) node[below]{$y=\arccot(x)$};
\end{tikzpicture}
\end{document}
红色虚线只是为了表明“它有效”。
当然,用 来绘制这个图非常有意义pgfplots
。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{amsmath}
\DeclareMathOperator{\arccot}{arccot}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[trig format plots=rad,
samples=101,
unbounded coords=jump,
xmin=-10,xmax=10,ymax=pi/2+0.5
]
\addplot[blue,thick,variable=\t,domain=-pi/2+0.1:pi/2-0.1] ({tan(\t)},\t);
\path (10,pi/2) node[above left]{$y=\arctan(x)$};
\addplot[red,dashed,thick,variable=\t,domain=-10:10] (\t,{atan(\t)});
\addplot[green!60!black,variable=\t,domain=-pi/2+0.1:pi/2-0.1] ({cot(\t)},\t);
\draw[green!60!black,dashed] (0,-2) -- (0,2);
\path (10,0) node[below left]{$y=\arccot(x)$};
\end{axis}
\end{tikzpicture}
\end{document}
或者,根据要求,不带盒子,但带有网格。
\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\arccot}{arccot}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[axis lines=middle,xlabel={$x$},ylabel={$y$},
width=0.9\textwidth,
trig format plots=rad,
samples=101,
unbounded coords=jump,
xmin=-pi,xmax=pi,
ymin=-pi/2-0.2,ymax=pi/2+0.5,
xtick={-pi/2,pi/2},xticklabels={$-\frac{\pi}{2}$,$\frac{\pi}{2}$},
ytick={-pi/2,pi/2},yticklabels={$-\frac{\pi}{2}$,$\frac{\pi}{2}$},
grid=major,grid style={densely dashed},
legend style={at={(0.01,0.99)},anchor=north west}
]
\addplot[blue,thick,variable=\t,domain=-pi/2+0.1:pi/2-0.1] ({tan(\t)},\t);
\addlegendentry{$y=\arctan(x)$}
%\addplot[red,dashed,thick,variable=\t,domain=-10:10] (\t,{atan(\t)});
\addplot[green!60!black,variable=\t,domain=-pi/2+0.1:pi/2-0.1] ({cot(\t)},\t);
\draw[green!60!black,dashed] (0,-2) -- (0,2);
\addlegendentry{$y=\arccot(x)$}
\end{axis}
\end{tikzpicture}
\caption{``Standard'' branches of the multivalued functions $\arctan$ and $\arccot$.}
\end{figure}
\end{document}