I'm using PGFPlots to graph some functions, and I'm facing the following problem: I need to plot the following function f over this interval:
It can be verified that in the left point of the interval, f has a value of 1. Nonetheless, when I plot f I get this result (the red and teal lines are for my guidance):
As you can see, the value of f in the left point is not plotted. I used the default samples to plot (25) and I count only 24 points. The problem is worse later, because I have to plot atan(f(x)), and this causes two errors:
Missing number, treated as zero. ...\x^(1-\ga)-\km)/(\co*\x^(1-\ga)+\km)))))};
Illegal unit of measure (pt inserted). ...\x^(1-\ga)-\km)/(\co*\x^(1-\ga)+\km)))))};
How can I fix this? I realized that plotting from the left point plus a little number fixes this, but nothing more. I provide a MWE to plot f. Thank you very much in advance.
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14} % this is to avoid a backwards compatibility warning
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}% function
\pgfmathsetmacro{\T}{1};
\pgfmathsetmacro{\co}{1};
\pgfmathsetmacro{\km}{4};
\pgfmathsetmacro{\ga}{0.1};
\pgfmathsetmacro{\la}{((\km/\co)^(1/(1-\ga))};
\pgfmathsetmacro{\lb}{((sqrt(5)-1)*\km/\co)^(1/(1-\ga))};
\begin{axis}[domain=\la:\lb]
\addplot {sqrt( (2*sqrt( \km*\co*\x^(1-\ga)*(\co*\x^(1-\ga)-\km)/(\co*\x^(1-\ga)+\km) )+\km)/(\co*\x^(1-\ga)-2*sqrt( \km*\co*\x^(1-\ga)*(\co*\x^(1-\ga)-\km)/(\co*\x^(1-\ga)+\km))))};
\addplot[color=teal] coordinates {(\la,{rad(atan(1))})(\lb,{rad(atan(1))})};
\addplot[color=red] coordinates {(\la,0.8)(\la,1.85)};
\addplot[color=red] coordinates {(\lb,0.8)(\lb,1.85)};
\end{axis}
\end{tikzpicture}
\end{document}
EDIT: I've just realized that, although my LaTeX editor throws the aforementioned errors when atan() or rad(atan()) is added, it still generates a .pdf. By ploting this
\addplot {rad(atan(sqrt( (2*sqrt( \km*\co*\x^(1-\ga)*(\co*\x^(1-\ga)-\km)/(\co*\x^(1-\ga)+\km) )+\km)/(\co*\x^(1-\ga)-2*sqrt( \km*\co*\x^(1-\ga)*(\co*\x^(1-\ga)-\km)/(\co*\x^(1-\ga)+\km))))))};
the result is this




\la+0.0001. Or use unequal sampling. For example https://tex.stackexchange.com/a/361112/51022 – Symbol 1 Jun 07 '17 at 04:52