Le 21/02/2016 23:15, Nils Bruin a écrit :
On Sunday, February 21, 2016 at 10:10:10 AM UTC-8, tdumont wrote:I have students who want to compute decimals of pi...so, what can we do with RealField(n) ? I make the following script (pi.sage): ------------------------ for p in [2..10]: R=RealField(10^p) pii=4*atan(R(1)) print p,R,pii ------------------------ Note that a single element of RealField(10^10) needs more than a Gigabyte to be represented. I don't think it's reasonable to expect that on a normal machine, with general purpose code (that will not try to minimize allocating intermediate results in separate memory!), a call like "atan" will work in reasonable time. Normally, evaluating R=RealField(5^10) 4*atan(R(1)) still finishes in reasonable time. It seems that your interruption left a corruption somewhere. It would be useful if you can get a fairly reliable way of producing the state in which you get NaNs. Then debugging might be an option. In the mean time, I don't think there's an issue for teaching: Just stick to a few less bits precision. 10^10 bits of precision is a little insane. That's the domain where you'd expect to need special-purpose code that takes care to not waste memory.
I agree, they are programming the Machin and Machin-like formulas. The question whas just: what can we do naively. Trying to find the corruption does not seem easy...
Then, using sage 7.0 or 7.1.beta4: attach("pi.sage") This produces a lot of seemingly correct output, but, as it takes a too long time to finish :-), I interrupt the computation (Ctrl-c). So, lets try again; replace 10 by 5 in the for statement (I do not leave sage). I get NaNs: 2 Real Field with 100 bits of precision NaN 3 Real Field with 1000 bits of precision NaN 4 Real Field with 10000 bits of precision NaN 5 Real Field with 100000 bits of precision NaN ..... Strange. Yours t.d. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com <mailto:sage-support+unsubscr...@googlegroups.com>. To post to this group, send email to sage-support@googlegroups.com <mailto:sage-support@googlegroups.com>. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
-- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
<<attachment: tdumont.vcf>>