Contents - Index


SUM

 

There are two forms for the SUM function.  EES determines which format is in use by context.

 

Index Form

SUM(Arg, i=1,50) returns the sum of a series of terms.  The index is represented as i here but it can be any EES variable name.  The lower and upper limits must be integers or variables that have been previously assigned to integer values.  The function is best explained by examples. SUM(j, j=1,4) will return 1+2+3+4 or 10.  The SUM function is most useful when used with array variables, e.g., X[j].  For example, the scalar product of two vectors, X and Y, each with 10 elements can be obtained as SUM(X[j]*Y[j], j=1,10).  The SUM function can be used with array variables to manipulate matrices.  Note that the limits appear in the Sum command must be integers or EES variables that have been previously set to integer values.  The following equations would be valid.

 

N=50

S=SUM(X[i], i=1,N)

 

List Form

SUM(Arg1, Arg2, ...ArgN) returns the sum of the arguments.  Array range notation is particularly convenient for the list form.  For example, SUM(X[1..100]) returns the sum of the 100 elements in the X array. Note, however, that mathematical operations within the List Form of the Sum function is not provided.  For example:

 

Z=SUM(0.1*X[1..100]) "This will not work!!!!!'

 

If mathematical operations are required, do them in separate equations or use the Index Form.

 

Mathematical functions