Gnuplot rechnet falsch?

Gast #1072781
Lesenswert?

Ich versuche mit Gnuplot eine Funktion zu plotten:

f(x) = (8/3)*(7*x**3 - 35*x**4 + 112*x**5 - 224*x**6 + 256*x**7 - 
128*x**8)

Mit Maxima sieht das so aus.


An der Stelle 0.5 sollte der Wert 0.5 sein.

-> Gnuplot liegt um 1/8 drunter. Was verpeile ich?
Gast #1072793
Lesenswert?

gnuplot> f(x) = (8/3)*(7*(x**3) - 35*(x**4) + 112*(x**5) - 224*(x**6) + 
256*(x**7) - 128*(x**8))
gnuplot> print f(0.5)
0.375
gnuplot>

verstehe ich nicht. 3/8 sind zwar 0.375, aber es gibt keinen 
zusammenhang. und der andere faktor sollte sein 0.1875
Gast #1072799
Lesenswert?

Der Bruch ist schuld:

7.5 My formulas (like 1/3) are giving me nonsense results! What's going 
on?

Gnuplot does integer, and not floating point, arithmetic on integer 
expressions. For example, the expression 1/3 evaluates to zero. If you 
want floating point expressions, supply trailing dots for your floating 
point numbers. Example:

gnuplot> print 1/3
                0
gnuplot> print 1./3.
                0.333333

This way of evaluating integer expressions is shared by both C and 
Fortran.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren