sum - Maple Help

Numerical Summation

Calling Sequence

 evalf(Sum(f, x=a..b, formal=c)) $\mathrm{evalf}\left({\sum }_{x=a}^{b}f\right)$ evalf(sum(f, x=a..b, formal=c)) $\mathrm{evalf}\left(\sum _{x=a}^{b}f\right)$ evalf(Sum(f, x=RootOf(g(_Z)))) evalf(sum(f, x=RootOf(g(_Z))))

Parameters

 f - algebraic expression; the summand x - name; the variable of summation a, b - endpoints of the interval of summation (can be infinite) c - (optional) either $\mathrm{true}$ or $\mathrm{false}$ g(_Z) - algebraic expression with a finite number of roots in Z

Description

 • The most common command for numerical summation is evalf(Sum(f, x=a..b)) where the summation command is expressed in inert form to avoid first invoking the symbolic summation routines. It is also possible to invoke evalf on an unevaluated sum returned by the symbolic sum command, as in evalf(sum(f, x=a..b)), if it happens that symbolic sum fails (returns an unevaluated sum).
 • You can enter the command evalf/Sum using either the 1-D or 2-D calling sequence. For example, evalf(Sum(1/(x^2+1), x=-5..5)) is equivalent to $\mathrm{evalf}\left({\sum }_{x=-5}^{5}\frac{1}{{x}^{2}+1}\right)$
 • The evalf(Sum()) command attempts to compute a result that is accurate to within 1 ulp at the current setting of Digits, so increasing Digits increases the requested accuracy of the result.
 • The summand f may be another unevaluated sum or integral, that is, nested forms are supported.

Method

 • In the case of finite sums, or sums over RootOfs, the sum is computed directly through numerical evaluation of the summand.
 • In the case of infinite sums, Levin's u-transform is used, which has the additional effect that sums that formally diverge may return a result that can be interpreted as evaluation of the analytic extension of the series for the sum (see the examples below).
 • This behavior can be controlled through the use of the formal option or the _EnvFormal environment variable. If this variable is assigned the value false, or formal=false is specified, then this command will apply some (numeric) convergence tests to determine if the infinite sum in question is convergent, divergent, or otherwise non-convergent.

Examples

Below are evaluation of sums over RootOf.

 > $\mathrm{Sum}\left(\mathrm{exp}\left(x\right),x=\mathrm{RootOf}\left({\mathrm{_Z}}^{5}+\mathrm{_Z}+1\right)\right)$
 ${\sum }_{{x}{=}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{5}}{+}{\mathrm{_Z}}{+}{1}\right)}{}{{ⅇ}}^{{x}}$ (1)
 > $\mathrm{evalf}\left(\right)$
 ${4.791792042}{+}{0.}{}{I}$ (2)

Here are some examples of finite sums approaching infinity, and an infinite sum.

 > $\mathrm{evalf}\left(\mathrm{Sum}\left(\frac{1}{{x}^{2}+1},x=-5..5\right)\right)$
 ${2.794570136}$ (3)
 > $\mathrm{evalf}\left(\mathrm{Sum}\left(\frac{1}{{x}^{2}+1},x=-20..20\right)\right)$
 ${3.055883631}$ (4)
 > $\mathrm{evalf}\left(\mathrm{Sum}\left(\frac{1}{{x}^{2}+1},x=-100..100\right)\right)$
 ${3.133448418}$ (5)
 > $\mathrm{evalf}\left(\mathrm{Sum}\left(\frac{1}{{x}^{2}+1},x=-\mathrm{\infty }..\mathrm{\infty }\right)\right)$
 ${3.153348095}$ (6)

An example with nesting.

 > $\mathrm{xpr}≔\mathrm{Int}\left({\mathrm{BesselK}\left(0,\mathrm{sqrt}\left({\left(2n+1\right)}^{2}+{x}^{2}\right)\right)}^{2},x=-\mathrm{\infty }..\mathrm{\infty }\right)$
 ${\mathrm{xpr}}{≔}{{\int }}_{{-}{\mathrm{\infty }}}^{{\mathrm{\infty }}}{{\mathrm{BesselK}}{}\left({0}{,}\sqrt{{\left({2}{}{n}{+}{1}\right)}^{{2}}{+}{{x}}^{{2}}}\right)}^{{2}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{x}$ (7)
 > $\mathrm{evalf}\left(\mathrm{Sum}\left(\mathrm{xpr},n=0..\mathrm{\infty }\right)\right)$
 ${0.3088174675}$ (8)

The following is a case where Levin's u-transform computes the values for the analytic extension of the sum.

 > $\mathrm{evalf}\left(\mathrm{Sum}\left(\frac{1}{\mathrm{sqrt}\left(x\right)},x=1..10\right)\right)$
 ${5.020997899}$ (9)
 > $\mathrm{evalf}\left(\mathrm{Sum}\left(\frac{1}{\mathrm{sqrt}\left(x\right)},x=1..100\right)\right)$
 ${18.58960382}$ (10)
 > $\mathrm{evalf}\left(\mathrm{Sum}\left(\frac{1}{\mathrm{sqrt}\left(x\right)},x=1..1000\right)\right)$
 ${61.80100877}$ (11)
 > $\mathrm{evalf}\left(\mathrm{Sum}\left(\frac{1}{\mathrm{sqrt}\left(x\right)},x=1..\mathrm{\infty }\right)\right)$
 ${-1.460354509}$ (12)

The infinite sum diverges.

 > $\mathrm{sum}\left(\frac{1}{\mathrm{sqrt}\left(x\right)},x=1..\mathrm{\infty }\right)$
 ${\mathrm{\infty }}$ (13)

This can be seen as a sum from the analytic extension of Zeta:

 > $\mathrm{\zeta }\left(z\right)=\mathrm{Sum}\left(\frac{1}{{i}^{z}},i=1..\mathrm{\infty }\right)$
 ${\mathrm{\zeta }}{}\left({z}\right){=}{\sum }_{{i}{=}{1}}^{{\mathrm{\infty }}}{}\frac{{1}}{{{i}}^{{z}}}$ (14)
 > $\mathrm{evalf}\left(\mathrm{eval}\left(,z=\frac{1}{2}\right)\right)$
 ${-1.460354509}{=}{-1.460354509}$ (15)

or using 'sum':

 > $\mathrm{_EnvFormal}≔\mathrm{true}:$
 > $\mathrm{sum}\left(\frac{1}{\mathrm{sqrt}\left(x\right)},x=1..\mathrm{\infty }\right)$
 ${\mathrm{\zeta }}{}\left(\frac{{1}}{{2}}\right)$ (16)
 > $\mathrm{forget}\left(\mathrm{evalf}\right):$$\mathrm{evalf}\left(\mathrm{Sum}\left(\frac{1}{\mathrm{sqrt}\left(x\right)},x=1..\mathrm{\infty }\right)\right)$
 ${-1.460354509}$ (17)
 > forget(evalf): evalf(Sum(1/sqrt(x), x=1..infinity, formal=false));
 ${Float}{}\left({\mathrm{\infty }}\right)$ (18)
 > $\mathrm{_EnvFormal}≔\mathrm{false}:$
 > $\mathrm{forget}\left(\mathrm{evalf}\right):$$\mathrm{evalf}\left(\mathrm{Sum}\left(\frac{1}{\mathrm{sqrt}\left(x\right)},x=1..\mathrm{\infty }\right)\right)$
 ${Float}{}\left({\mathrm{\infty }}\right)$ (19)
 > $\mathrm{_EnvFormal}≔'\mathrm{_EnvFormal}':$

References

 Fessler, T.; Ford, W.F.; and Smith, D.A. "HURRY: An acceleration algorithm for scalar sequences and series." ACM Trans. Math. Software, Vol. 9, (1983): 346-354.
 Levin, D. "Development of non-linear transformations for improving convergence of sequences". Internat. J. Comput. Math, Vol. B3, (1973): 371-388.

Compatibility

 • The c parameter was introduced in Maple 2016.