绘制反正切

绘制反正切

我一直在尝试绘制反正切函数

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
\pgfkeys{/pgf/declare function={arctanh(\x) = 0.5*ln(1+\x)/ln(1-\x);}}
\vspace{1cm}

\begin{tikzpicture}[trim axis left]
\begin{axis}[
  xmin=-1, xmax=1,
  ymin=-1, ymax=1,
  samples=100,
  enlarge x limits=false,
  grid=both,
  no markers,
  axis equal]
\addplot +[thick] {arctanh(x)};
\end{axis}
\end{tikzpicture}
\end{document}

但看起来不对,我做错了什么?

答案1

它看起来不正确,因为 的定义中有一个小错误arctanh

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
\pgfkeys{/pgf/declare function={arctanh(\x) = 0.5*(ln(1+\x)-ln(1-\x));}}
\vspace{1cm}

\begin{tikzpicture}[trim axis left]
\begin{axis}[
  xmin=-1, xmax=1,
  ymin=-1, ymax=1,
  samples=100,
  enlarge x limits=false,
  grid=both,
  no markers,
  axis equal]
\addplot +[thick] {arctanh(x)};
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

或者,与您的表示形式稍微更接近,并且避免警告的域。

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}

\begin{document}
\pgfkeys{/pgf/declare function={arctanh(\x) = 0.5*(ln((1+\x)/(1-\x)));}}
\vspace{1cm}

\begin{tikzpicture}[trim axis left]
\begin{axis}[
  xmin=-1, xmax=1,
  ymin=-1, ymax=1,
  samples=100,
  enlarge x limits=false,
  grid=both,
  no markers,
  axis equal]
\addplot +[thick,domain=-0.99:0.99] {arctanh(x)};
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

为了比较目的:运行xelatex

\documentclass{article}
\usepackage{pstricks,pst-math,pst-plot}
\begin{document}
\begin{pspicture}[algebraic](-5,-4)(5,4)
\psaxes{->}(0,0)(-5,-4)(5,4)
\psplot[linewidth=1.5pt,linecolor=blue]{1}{5}{ACOSH(x)}
\psplot[linewidth=1.5pt,linecolor=red]{-5}{5}{ASINH(x)}
\psplot[linewidth=1.5pt,linecolor=green]{-.999}{.999}{ATANH(x)}
\end{pspicture}

\end{document}

在此处输入图片描述

相关内容