On Sunday, 16 April 2023 at 19:47:15 UTC-7 aw wrote:

Here's what users expect when they type an expression into a 
higher-precision environment: they expect the answer to be the exact 
answer, truncated to the precision of that environment. Period. This is not 
negotiable. There is no latitude for the software to deviate from that.

When I type 2*1.1 into an environment with a precision of 200 bits, I 
expect the answer to be the exact answer truncated to 200 bits, or about 59 
digits.

 

Here's what Sage gives me:

RealField(200)(2*1.1)
2.2000000000000001776356839400250464677810668945312500000000

As far as I can see, when you specify 1.1, I'd expect about 2 digits, i.e., 
about 7 bits of precision. If you want 59 digits of precision then write it!
sage: a=1.1000000000000000000000000000000000000000000000000000000000
sage: RealField(200)(2*a)
2.2000000000000000000000000000000000000000000000000000000000

That's what I was taught in school about implying precision in decimal 
fractions, so the fact that sage does the same thing as what I was taught 
in school actually surprises me pleasantly here. I'm not talking university 
here. Just high school, physics, chemistry, basic maths etc.

We discussed before that the interpreter sees "2*1.1" before it ever gets 
near the RealField(200), so as far as "2*1.1" is concerned, there is no 
precision implied there other than the approximately 7 bits of precision in 
1.1.

At this point I think it's clear that *your* expectation when  you write 
1.1 is rational arithmetic. That's not what it means in python and that's 
not what it means in sage.

And defaults should always be what most users expect (especially when it's 
99%+ of users, as it is in the case).


I think more than 1% of sage's user base received an education similar to 
mine (no value judgement in either direction implied!) so I don't agree 
with your 99% claim there.

If you prefer, you can make sage behave in the way you like by just 
including a little definition in your configuration file:

old_RealNumber=RealNumber
def RealNumber(*args,*kwargs):
    return QQ(old_RealNumber(*args,*kwargs))

With that you'll be good to go. The preparser will do exactly what you 
expect. There are always going to be differences in preference and 
expectation for what the user interface provides (by default). So rather 
than argue about tastes, perhaps just tailor your environment to your 
preferences.

Give it a try! Perhaps it works for you. Or perhaps you find it makes other 
things work poorly, in which case you may gain some insight why the design 
decision in sage was made as it is.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/c2845ef5-4e22-4f47-b1e4-dab454604842n%40googlegroups.com.

Reply via email to