While I used pgfplots with gnuplot successfully several times, I cannot find the cause of the following problem:
I'm trying to plot the graph of a function which you can see here: f(x)=(36/25) + (336*x)/125 - (6*x^2)/5 + (24*x^3)/125 - (x^4)/100.
When I plot the function with programs like GeoGebra or calculate values "by hand", I can clearly see that f(6)=0. Yet, the output of
\documentclass[a4paper,11pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{pgf,tikz}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot gnuplot[domain=3:7] {-(36/25) + (336*x)/125 - (6*x^2)/5 + (24*x^3)/125 - (x^4)/100};
\end{axis}
\end{tikzpicture}
\end{document}
is the following and it clearly shows f(6)>0.
To me it looks like the resulting graph needs to be moved downwards to get the correct graph. To make matters worse, I also encountered the following unecpected behaviour: If I subsitute
- (x^4)/100
with
- 1/100 * x^4
the result will be different (yet still not correct).
Since other functions of very similar structure got plotted seemingly correctly, I'm unable to find the cause of the problem myself and hope that someone can help me.
Like C
, gnuplot uses integer division if both values are integers:
gnuplot print 1/100
0
gnuplot print 1/100.0
0.01