![使用 pgfplots 输出的反正弦值不正确](https://linux22.com/image/460336/%E4%BD%BF%E7%94%A8%20pgfplots%20%E8%BE%93%E5%87%BA%E7%9A%84%E5%8F%8D%E6%AD%A3%E5%BC%A6%E5%80%BC%E4%B8%8D%E6%AD%A3%E7%A1%AE.png)
\documentclass[10pt, oneside]{article}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.9}
\begin{document}
\begin{tikzpicture}[scale=0.75]
\begin{axis}[
axis lines = left,
ymax=1,
ymin=0,
xlabel = \( x \),
ylabel = {\( f(x) \)},
xtick={0,1},
xticklabels={$0$,$1$},
ytick={0,1},
yticklabels={$0$,$1$},
]
\addplot[domain=0:1, samples = 500, color=red, style=very thick] {(2 / pi)*asin(sqrt(x)) };
\end{axis}
\end{tikzpicture}
\end{document}
这是什么原因造成的?该如何解决?
答案1
您可能错误地认为三角函数默认以弧度为单位。
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=left,
ymin=0, ymax=1,
xlabel=\(x\),
ylabel={\(f(x)\)},
xtick={0,1}, ytick={0,1},
trig format plots=rad,
]
\addplot[red, very thick, domain=0:1, samples=200, smooth] {(2/pi)*asin(sqrt(x))};
\end{axis}
\end{tikzpicture}
\end{document}