MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Alternating sums of large numbers

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
> question is actually about this.
> 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...
> I would very much appreciate your advice on such problem.
> Many thanks in advance,
> 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


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

  • 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