Previous Page Contents

numeric::sum -- numerical approximation of sums (the float attribute of sum)

Introduction

numeric::sum(f[i], i=a..b) computes a numerical approximation of sum(f[i],i=a..b).

numeric::sum(f(x), x = RootOf(p(X), X)) computes a numerical approximation of sum(f(x), x=RootOf(p(X), X)).

Call(s)

numeric::sum(f[i], i = a..b))
float(hold(sum)(f[i], i = a..b))

float(freeze(sum)(f[i], i = a..b))

numeric::sum(f(x), x = RootOf(p(X), X)))

float(hold(sum)(f(x), x = RootOf(p(X), X)))

float(freeze(sum)(f(x), x = RootOf(p(X), X)))

Parameters

f[i] - an arithmetical expression in i
i - the summation index: an identifier or an indexed identifier
a, b - integers or +/-infinity satisfying a<=b
f(x) - an arithmetical expression in x
x - the summation variable: an identifier or an indexed identifier
p(X) - a univariate polynomial in X
X - the indeterminate of p: an identifier or an indexed identifier

Returns

a floating point number.

Related Functions

_plus, int, numeric::quadrature, sum

Details

Example 1

We demonstrate some equivalent calls for numerical summation:

>> numeric::sum(1/i!, i = 0..infinity),
   float(hold(sum)(1/i!, i = 0..infinity)),
   float(freeze(sum)(1/i!, i = 0..infinity))
                   2.718281829, 2.718281829, 2.718281829

MuPAD's symbolic summation does not find a simple representation of the following sum:

>> sum(1/i!/(i+1)!, i = 0..infinity)
                   /          1                           \
                sum| -------------------, i = 0..infinity |
                   \ fact(i) fact(i + 1)                  /

The following float evaluation calls numeric::sum:

>> float(%)
                                1.590636855

The exact value of the following sum is PI*coth(PI):

>> numeric::sum(1/(1+i^2), i = -infinity..infinity) =
   float(PI*coth(PI))
                         3.153348095 = 3.153348095

Example 2

The following sum cannot be evaluated numerically because of the symbolic parameter x:

>> numeric::sum(1/(x+i^2), i = -infinity..infinity) 
      Error: first argument may only contain i as symbolic parameter\
       [numeric::sum]

Example 3

We demonstrate numerical cancellation when summing the Taylor series for exp(-20):

>> exp(-20.0) <> numeric::sum((-20)^i/i!, i = 0..100)
               0.000000002061153622 <> 0.000000002068277833

Also the infinite sum suffers from cancellation:

>> exp(-20.0) <> numeric::sum((-20)^i/i!, i = 0..infinity)
               0.000000002061153622 <> 0.000000002068334676

Cancellation can be avoided using a finite sum with exact terms:

>> exp(-20.0) = float(_plus((-20)^i/i! $ i = 0..100))
                0.000000002061153622 = 0.000000002061153622

Example 4

The following call computes the numerical roots of the polynomial in the RootOf expression and sums over all the roots:

>> numeric::sum(exp(x)/x, x = RootOf(X^10 - X - PI, X))
                                9.681693381

Background

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000