5

I've been trying to plot the arctanh function for a while now

\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}

but it doesn't look right, what am I doing wrong?

7

It does not look right because there is a small mistake in the definition of 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}

enter image description here

Or, a somewhat closer representations to yours and a domain that avoids the warnings.

\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}

enter image description here

4

For comparism purpose: run with 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}

enter image description here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.