octave-maintainers
[Top][All Lists]
Advanced

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

Re: Symbolica package warning: Using rat() heuristics for double-precisi


From: Colin Macdonald
Subject: Re: Symbolica package warning: Using rat() heuristics for double-precision input (is this what you wanted?)
Date: Fri, 17 Feb 2017 12:51:03 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1

On 17/02/17 12:26, Przemek Klosowski wrote:
On 02/17/2017 02:45 PM, Colin Macdonald wrote:
50 is just an accident.  I don't think its even really 50: I suspect
if you check its not accurate much past 15.
You're right, of course:

1.570796326794896557998981734272092580795288085937500000 octave
1.570796326794896619231321691639751442098584699687552910 maxima

1.234567890123456

Still, rats(...,16) maybe is better? Maybe also more assertive error
message, e.g. "using the rational approximation, limiting accuracy to
approx. single precision"

I'm not sure... it would be kind of annoying to get something like "24689/12344*pi" instead of "pi/2".

I'd be willing to revisit this, if there is a more sensible default. Can you help? File an issue [1], and we'll continue discussing there.
[1] https://github.com/cbm755/octsympy/issues/

One option is to not use "rats" and have SymPy do the conversion:
````
>>> Rational(2.3)
2589569785738035/1125899906842624
>>> Rational(1.25)
5/4
>>> Rational(1.24)
5584463537939415/4503599627370496
>>> Rational(math.pi/2)
884279719003555/562949953421312
````
I suspect (but have not verified) that these are the rational numbers corresponding to the exact value of the given floating point numbers. Perhaps that is the best behaviour... What do you think?

thanks,
Colin



reply via email to

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