# Function won't plot (“dimension too large” error)

I want to plot this function (excuse me, I don't know how to write equations on this forum):

f(x) = -2*arccos(0.5*e^(ln(4)/x) -1) + pi

When I enter the code (shown below) in pgfplots, I get a error that says "dimension too large". I've tried to put x, and the whole inside of the arccos in deg(), I've restricted the y domain to 2:8 (so it is continues), but nothing seems to work. The only way I don't get an error, is by removing the deg(). However, then I get an empty grid where no function is shown. Does anyone know how to get this function plotted?

\begin{figure}[H]
\begin{tikzpicture}[scale=1.3, transform shape]
\begin{axis}[xmin=-8, xmax=8, ymin=-4, ymax=4, restrict y to domain=-8:1, axis x line=center, axis y line=center]
{-2*acos( 0.5*e^(ln(4)/x) -1 )+pi};
\end{axis}
\end{tikzpicture}
\centering
\label{fig:thetafunction}
\end{figure}


Here you can find how the plot should look like.

• In your definition of f(x) I see an exponential function, but in the code below you write 2^... Is this a typo or which function are you exactly trying to plot? – Sito Dec 9 '18 at 16:40

I don't understand what you exactly wanted to do with the ydomain, since your function only depends on x. The problem was that the acos functions returns the answer in degrees, but you want it in rad (if I understood you correctly). See this answer. Also, I'm not sure if one could handle the domain problem better, but since your x is in the denominator, you have a problem at x=0. I just split the domain into two parts, feel free to change the bounds as necessary for you. Hope this works for you.

\documentclass[10pt]{article}
\usepackage{pgfplots}