help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: variable precision arithmetic (vpa) errant results in windows 10, oc


From: Reik Reid
Subject: Re: variable precision arithmetic (vpa) errant results in windows 10, octave-4.0.1
Date: Wed, 22 Jun 2016 11:26:32 -0700

Thanks, Colin. Indeed I made a blunder. I included quotes when I tested on linux but no quotes when I tested in windows. A warning sounds like a good idea, perhaps something like

"vpa: unquoted expressions made only of numerical constants (numbers) will be evaluated as double floats before being passed into vpa (is that what you wanted?)"

But I am at the same time a bit surprised by how sym() works, and wondering whether vpa() should behave the same way or not. It looks to me like sym gives a warning but then actually gets the accurate answer anyway, as follows:

x = vpa (sym (1 / 3), 20)
warning: Using rat() heuristics for double-precision input (is this what you wanted?)
warning: called from
    sym at line 225 column 7
    vpatest at line 11 column 3
x = (sym) 0.33333333333333333333
3 * x
ans = (sym) 1.0000000000000000000

That is surprising to me. It appears that the argument to sym() is not evaluated by the octave parser, but rather by the sym() function itself, whether the argument is a (quoted) string or not! Clearly I lack knowledge of how the internals of octave function calls work, but this surprised me! Let me pose the following question: If vpa() behaved the same way as sym(), would leaving out the quotes be safe for all cases of constant numerical expressions? Is that a desirable behavior?

I'm not intentionally trying to stir up any trouble here, just wondering what the thinking and mechanism behind the observed behavior is. Perhaps also I have misunderstood something ;).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]