# Help: Sum Function

SUM(N,A,B,X) produces the sum of the expression X for values of the dummy variable N in the range from A to B. The initial value is A, and is increased by 1 each time, stopping when it exceeds B. Thus SUM(N,1,3,N^2) produces 1^2 + 2^2 + 3^2 = 14, and so does SUM(N,1,3.5,N^2). SUM(N,3,1,N^2) produces 0, since the initial value is already greater than the final value.

The dummy variable can be any single letter "A" to "Z". If it already represents a variable or parameter, its current value is restored after the SUM is complete. If more than one dummy variable is active at the same time, they should have different letters - e.g. SUM(I,SUM(J,... is fine but SUM(I,SUM(I,... is wrong.

The initial and final values may be expressions, but should not contain the dummy variable. The expression "X" will usually contain the dummy variable. Any other variables that occur in "X" will keep the same values throughout the sum - even if they depend on the dummy variable, they will NOT be re-evaluated for each new value of the dummy variable.