If you don't need nicely formatted input and output, you can add even
greater flexibility by programming § and I§ as user-defined functions.
This has the great advantage of letting you insert summations into
bigger expressions.
A. For finite sums, STOre the following program in the variable '§' (§
= sigma (SHIFT+V)):
<<
-> v ii fi s
<<
0 ii fi FOR x
x 'v' EVAL STO s EVAL +
NEXT
'v' EVAL PURGE
Now you can use this newly created function like every built-in
function:
I) Either put the following 4 arguments on the stack an press §:
4: name of index variable
3: initial value of index variable
2: final value of index variable
1: summand
For example: 'n' 1 10 'n^2' § => 385
II) Or use the algebraic syntax:
'§(name,initial_value,final_value,summand)'
In our example, this would be: '§(n,1,10,n^2)'
You can, of course, EVALuate this expression directly, but you can
also use it within any other expression or equation, like this:
'15+§(n,1,10,n^2)' EVAL => 400
And you can even use *symbolic* index values, as in this expression:
________________
/ n
/ 1 ---
-- / ----- > x^2
\/ n-1 ---
x=1
http://www.wolframalpha.com/input/?i=%28SQRT%28%281%2F%28n-1%29%29*sum_{x%3D1}^n+x^2%29%29
Here is all you have to do: '\v/(1/(n-1)*§(x,1,n,x^2))' (where \v/
represents the symbol for "square root")
If you now store the real number 5 in the variable 'n', the expression
EVALuates to 3.70809924355
http://www.wolframalpha.com/input/?i=%28SQRT%28%281%2F%28n-1%29%29*sum_{x%3D1}^n+x^2%29%29
B. For infinite sums, STOre the following program in the variable
'I§':
<<
-> v ii s
<<
s 0 ii
DO
DUP 'v' EVAL STO
3 PICK EVAL
SWAP 1 +
ROT ROT OVER +
DUP 4 ROLLD
UNTIL ==
END
ROT DROP2
'v' EVAL PURGE
Since the final index value is always +oo, there are only 3 arguments
to supply in this case:
I) Either:
3: name of index variable
2: initial value of index
1: summand
II) Or, in algebraic syntax:
'I§(name,initial_value,summand)'
The following expression, for example...
_______ +oo
/ --- x^2
-- / n+2 > -------
\/ --- 2^x
x=n
http://www.wolframalpha.com/input/?i=SQRT%28n%2B2%29*sum[x^2%2F2^x%2C+{x%2C+n%2C+%2Boo}]
...would be entered as:
'\v/(n+2)*I§(x,n,x^2/2^x)'
If, for instance, n=2 (STOre the real number 2 in 'n'), the expression
EVALuates to 11.
http://www.wolframalpha.com/input/?i=SQRT%282%2B2%29*sum[x^2%2F2^x%2C+{x%2C+2%2C+%2Boo}]
N.B.
1. Make sure the index variable name is not already in use (purge it,
if necessary).
2. You can't use 'i' as an index name, since it is reserved for
symbolic complex numbers.