Function parser error

Found a bug? Tell us about it here

Moderator: DPlotAdmin

Post Reply
akselfr
Posts: 15
Joined: Wed Dec 10, 2003 8:11 am

Function parser error

Post by akselfr »

I'm plotting some functions using the 'Generate -> Y=f(X)' option.
For some odd reason the following expression returns identically
zero for x in [0;3], dX=0.01

f(x) = 5.*(cosh(4.*x)+4.*cosh(2.*x)+3.)

If I build up the expression term by term, everything works fine,
until I enclose in parentheses. Then the result is exactly 0.

Any clues ?
I'm running version 1.9.8.5
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Aksel,
Thanks for pointing out the problem. The function parser doesn't like trailing decimal points in numbers. DPlot preprocesses the function before passing it to the parser and, among other things, eliminates trailing decimal points (all numbers are treated as doubles, so nothing is lost here). But I've somehow fouled up in this case and missed the last "3.", which throws off the parser. That's much more information than you need to know, just wanted to let you know what's going on here. If you instead use:

f(x) = 5*(cosh(4*x)+4*cosh(2*x)+3)

or

f(x) = 5.0*(cosh(4.0*x)+4.0*cosh(2.0*x)+3.0)

then you'll get the expected result. This will definitely be fixed in the next release; sorry for the inconvenience.
Visualize Your Data
support@dplot.com
Post Reply