On Tuesday, April 18, 2023 at 1:31:33 PM UTC-6 Nils Bruin wrote:

sage: R=RealLazyField()
sage: a=cos(R.pi()/13)
sage: a.numerical_approx(200)
0.97094181742605202715698227629378922724986510573900358858764
sage: a.numerical_approx(400)
0.970941817426052027156982276293789227249865105739003588587644526477041708760006676932574606408384261554438205497500991925
sage: a.numerical_approx(800)
0.970941817426052027156982276293789227249865105739003588587644526477041708760006676932574606408384261554438205497500991925446304849693046415555347324930136179166290724598721026150846791024698868142304028116956960541355031116767265861274416574


Nils, eager versus lazy is not the problem.

The problem is very simple: decimal literals like "1.1" are being 
mishandled when passed in expressions to RealField *or* RealLazyField. 

Here, look:

RealField(200)(e^1.1)
3.0041660239464333947978502692421898245811462402343750000000

RealLazyField(e^1.1).numerical_approx(200)
3.0041660239464333947978502692421898245811462402343750000000

RealLazyField()((e^1.1)).numerical_approx(400)
3.00416602394643339479785026924218982458114624023437500000000000000000000000000000000000000000000000000000000000000000000

These outputs purport to be the value of e^1.1 to 200 or 400 bits, but they 
are not. 

Any normal mathematician who writes "e^1.1" intends that to mean 
"e^(11/10)". They write "1.1" because it is less writing than 11/10. On a 
computer, 1.1 is 3 characters of typing, 11/10 is 5 characters of typing. 
So you find yourself typing 1.1 instead of 11/10.

It really is that simple.

Decimal literals, when typed into high-precison environments, are just a 
shorthand way of writing exact rationals.

You guys are silently giving "1.1" a different value, the nearest 53-bit 
approximation.

That value has no canonical relation to the exact rational.

That value has no canonical relation to the precision the user has 
requested.

It is an arbitrary value that no normal mathematician would choose 
themselves.

That is just a mistake. Plain and simple.

It is simple to fix.

So it should be fixed.

Here's how easy it is:

RealField(200)(e^(11/10))
3.0041660239464331120584079535886723932826810260162727621298

RealLazyField()((e^(11/10))).numerical_approx(200)
3.0041660239464331120584079535886723932826810260162727621298

RealLazyField()((e^(11/10))).numerical_approx(400)
3.00416602394643311205840795358867239328268102601627276212975286052863219354994639393702584656011004248292917244402984647

-aw

-- 
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/99af3f2e-b725-4c78-a5d6-db5f9f5fb98dn%40googlegroups.com.

Reply via email to