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