       Re: Alternating sums of large numbers

• To: mathgroup at smc.vnet.net
• Subject: [mg91902] Re: Alternating sums of large numbers
• From: David Bailey <dave at Remove_Thisdbailey.co.uk>
• Date: Fri, 12 Sep 2008 05:27:55 -0400 (EDT)
• References: <gaar1q\$156\$1@smc.vnet.net>

```AsMikhail Lemeshko wrote:
> Dear friends,
>
> I'm using a Mathematica 6, and I've faced with the following problem.
> Here is a copy of my Mathematica notebook:
>
> --------------------------------------------------------
>
> NN = 69.5;
>
> n = 7;
>
> coeff = (Gamma[2*NN - n + 1]*(2*NN - 2*n))/n!;
>
> f[z_] := Sum[((-1)^(\[Mu] + \[Nu])*Binomial[n, \[Mu]]*Binomial[n, \
> [Nu]]*Gamma[2*NN - 2*n + \[Mu] + \[Nu], z])/(Gamma[2*NN - 2*n + \[Mu]
> + 1]*Gamma[2*NN - 2*n + \[Nu] + 1]), {\[Mu],0, n}, {\[Nu], 0, n}];
>
> Plot[coeff*f[z], {z, 0, 100}]
>
> --------------------------------------------------------
>
> As you can see, I want to calculate a double alternating sum,
> consisting of large terms (products of Gamma-functions and binomial
> coefficients). Then I want to plot the result, in dependence on
> parameter z, which takes part in the summation as an argument of the
> incomplete Gamma-function, Gamma[2*NN - 2*n + \[Mu] + \[Nu], z].
>
> Apart from this, I have another parameter, n, which is an upper limit
> for both of sums, and also takes part in Gamma functions. When this
> parameter grows, the expression next to summation also increases. At
> some point, Mathematica begins to show very strange results - and my
>
> For instance, if the parameter n=5, everything is O.K., the plot shows
> a smooth curve. When we set n=6, there appears a little "noise" at
> 60<z<80, which is of no sense. This noise increases with n and is huge
> for n=8.
>
> A suppose that this error is caused by the huge numbers with
> alternating signs, contributing to the summation - probably there are
> some mistakes introduced by numerical evaluation. I tried to play with
> Accuracy etc., but it does not help. I also investigated the
> possibility that the error is introduced not by the summation, but by
> the product of big numbers. According to this, I tried to compute the
> sum of Exp[Log[Gamma]+Log[Gamma]...]    (the logarithm smoothly
> depends on z). But it does not help as well...
>
>
> Mikhail.
>
As you already realise, the alternating sums are generating rounding
error (noise) because your calculations are being done at machine
precision. Once Mathematica starts a calculation in machine precision,
it basically stays at that precision, so you need to ensure that the
real numbers entering your calculation are high precision. Thus you need
to set

NN=65.9000000000000000000000000000000000000000000000;

and also, Plot will by default inject real number values, which you can
override by using the WorkingPrecision option - setting it to some large
value - say 50. With both of these changes, you get a smooth graph.

David Bailey
http://www.dbaileyconsultancy.co.uk

```

• Prev by Date: Re: Re: How to simplify ArcCos[x/Sqrt[x^2+y^2]] to Pi/2-ArcTan[x/Abs[y]]?
• Next by Date: Re: Simulate a finite-state markov process
• Previous by thread: Re: Alternating sums of large numbers
• Next by thread: Re: Alternating sums of large numbers