The SUM Function

<< Click to Display Table of Contents >>

Navigation:  Problem Descriptor Reference > The Elements of a Descriptor > Built-in Functions >

The SUM Function

Previous pageReturn to chapter overviewNext page

The SUM function produces the sum of repetitive terms.  The form is:

 

value = SUM( name, initial, final, expression )

 

The expression argument is evaluated and summed for name = initial, initial+1, initial+2,...final.

 

For example, the statement:

 

source = SUM(i,1,10,exp(-i))

 

forms the sum of the exponentials exp(-1)+exp(-2)+...+exp(-10).

 

 

The SUM function may be used with data ARRAYs, as in

 

DEFINITIONS

   A = ARRAY(1,2,3,4,5,6,7,8,9,10)

   source = SUM(i,1,10,A[i])

 

Example:

Samples | Usage | Sum.pde