PGFplots:asin(deg(x)) - 维度太大

PGFplots:asin(deg(x)) - 维度太大

我在使用 pgfplots 时遇到问题。我不知道为什么 asin(deg(x)) 会给出“Dimension too large”错误。你能帮忙吗?我找不到任何解决方案,所以才问这个问题。这是代码。

\documentclass{report}
\usepackage[a4paper, portrait]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[czech]{babel}
\usepackage{graphicx}
\usepackage{float}
\usepackage{hyperref}
\usepackage{mathtools}
\usepackage{pgfplots}
\usepackage{color}
\pgfplotsset{compat=1.13}

\begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{axis}[
          xmax=2,xmin=-2,
          ymax=2,ymin=-2,
          xlabel=x,ylabel=y,
          xtick={-1.57, 1.57}, xticklabels={$-\pi$/2,$\pi$/2},
          ytick={-1.57, 1.57}, yticklabels={$-\pi$/2,$\pi$/2},
          axis lines=middle,
          axis equal, 
          legend style={at={(1.3,0.5)},anchor=center}
          ]
    \addplot[blue,domain=-pi/2:pi/2, samples=50] {sin(deg(x))};
    \addplot[red,domain=-1:1,samples=100]  {asin(deg(x))};
    \addplot[gray, dashed, domain=-1.7:1.7]  {x};
    \addlegendentry{$y = \sin x$}
    \addlegendentry{$y = \arcsin x$}
\end{axis}
\end{tikzpicture}
\end{figure}

谢谢!

答案1

asin以度为单位给出结果,因此您需要rad(asin(x))将其转换为弧度,因为这就是您要绘制的。

图像输出

\documentclass{report}
\usepackage[a4paper, portrait]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
          xmax=2,xmin=-2,
          ymax=2,ymin=-2,
          xlabel=x,ylabel=y,
          xtick={-1.57, 1.57}, xticklabels={$-\pi$/2,$\pi$/2},
          ytick={-1.57, 1.57}, yticklabels={$-\pi$/2,$\pi$/2},
          axis lines=middle,
          axis equal, 
          legend style={at={(1.3,0.5)},anchor=center}
          ]
    \addplot[blue,domain=-pi/2:pi/2, samples=50] {sin(deg(x))};
    \addplot[red,domain=-1:1,samples=100]  {rad(asin(x))};
    \addplot[gray, dashed, domain=-1.7:1.7]  {x};
    \addlegendentry{$y = \sin x$}
    \addlegendentry{$y = \arcsin x$}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

相关内容