Closed Benezivas closed 1 year ago
Just by eyeballing, there is a subexpression sqrt(-1+x^2)
but when plugging in the upper bound of 3/5
this evaluates to sqrt(-1+9/25) = 4/5*sqrt(-1)
which is not a real number. Keep in mind that pgfplots
is not a computer algebra system and does not perform any simplifications on the expression you provide.
Indeed, when you rewrite the expression by taking out a sqrt(-1)
from the numerator and the denominator it works just fine:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[scale=1.0]
\begin{axis}[ymin=1, ymax=10, xmin=0, xmax=0.8, xlabel=$x$, ylabel=$f(x)$, grid=major, samples=50] %
\addplot[domain=sqrt(21)-4:3/5] {((1+x)*(sqrt(1-x^2)+sqrt(17+16*x-x^2+16*3)))/(4*sqrt(1-x^2))};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
You are correct, I should have spotted this myself. I was so focused on finding an issue with the syntax of the expression that I did not stop to check the individual expressions extensively.
I am trying to plot a function inside a narrow domain interval, in which
pgfplots
claimsfor all coordinates of the domain. This is unexpected, since the function is defined and bounded in the given interval. I tried plotting the same function in wolframalpha and maxima:
which both output the expected plot.
Here is a minimal example file to reproduce the issue:
I checked the
pgf
documentation regarding mathematical notation and have not found any problems, but it may of course still be the case that the syntax I used is incorrect. Any help is appreciated.