Why not compute in QQ? Sage  is done for this...:

sage: s1=sum(10^(-q^2/10000) for q in range(-10000,10000))
(wait some time...)
sage: s2=sum(10^(-k^2/10000) for k in range(-20000,20000))
(drink a large cup of coffee)..

then:
sage: t=s1-s2

sage: float(t)
0.0
ok, let's try more precise:

sage: R=RealField(1000)
sage: R(t)
-1.02019..... e-1000

e-1000! ah, ah!

sage: R=RealField(100)
sage: R(t)
-1.0201972272249067475972377296e-10000

ok.
sage: R=RealField(53)
sage: R(t)
-1.02019722722491e-10000
ok!

BUT:
sage: RDF(t)
0.0

RDF and RealField(53) have the same mantissa, but not the same exposant size!

Yours
t.d.

Le 13/12/2010 09:47, Simon King a écrit :
Hi Chris,

disclaimer: I am no expert in numerics.

On 13 Dez., 07:34, Chris Seberino<cseber...@gmail.com>  wrote:
Why isn't the error improving as I increase the number of terms that
are summed?  Am I doing something wrong in Sage?  (Yes it is possible
that this infinite sum converges unimaginably slowly so I wanted to
check first I wasn't doing something dumb.)

I think you use a precision that is too small

The summands are of course very small. So, comparing the two results
in a field with 53 digits precision may be pointless:
   sage: sum(10^(-k^2/10000.0) for k in range(-20000,20000)) ==
sum(10^(-k^2/10000.0) for k in range(-10000,10000))
   True

Note that the denominator "10000.0" in your exponent belongs to RR,
which by default has 53 digits precision. Let us raise it to 6000:
   sage: d = RealField(6000)(10000)
   sage: d.precision()
   6000

Unfortunately, the sums are now taking a very long time to compute.
But we are only interested in their difference.
So, it suffices to do (still taking about one minute):
   sage: 2*sum(10^(-k^2/d) for k in range(10000,20000))
   2.02019722722490674759723772962542922944721452394745083...e-10000

So there is a small progress in the summation! But I have no idea
whether at the end of the day the small progress will be enough to
cover the big difference -1.27897692436818e-13 to your theoretical
result.

Cheers,
Simon


--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to