Discussion:
Question about my hp-28s
(too old to reply)
c***@hotmail.com.ar
2012-01-29 23:50:52 UTC
Permalink
Hi people, I have an hp-28s, and I would like to know if it is
possible to make a simple summatory like this:
http://www.wolframalpha.com/input/?i=%28sum_%7Bi%3D1%7D%5E6+i%29 in
that calculator, but also more complicated sums, or if it is possible
to make a program which does that. Wait for your answers. Thanks.

PD: I also have the original manuals, but it doesn´t appear.
Giuseppe Donnini
2012-02-07 18:03:43 UTC
Permalink
Summation functions are not implemented in the HP-28S, so you have to
write your own programs. I would suggest using general purpose
programs, so that you don't have to rewrite them for each particular
problem.

A. For finite sums, you could use a program like this:

<<
0 0 0 -> ii fi Smnd
<<
{ STO ii fi Smnd } MENU HALT
0 ii fi FOR x
x Smnd EVAL +
NEXT
23 MENU
DUP "§=" SWAP ->STR +
CLLCD 1 DISP
§ represents the greek letter "sigma" (SHIFT+V).

If you run this program (which you could STOre in the variable '§'),
you will be presented with a solver-like menu, where you can supply
(in any order you wish):

1. the initial index: ii (1 in your example)
2. the final index: fi (6 in your example)
3. the summand: Smnd, as a user-defined function of the form: << -> x
'F(x)'>>
(instead of x you can use any variable name you please, so your
example would be entered like this: << -> i 'i'>>)

If you are done, press CONT (SHIFT+1) and you will see a nicely
formatted result: §=21

Now, try a more complex one:
ii = 1
fi = 100
Smnd = << -> X '1/(X*(X+1))' >>
-------------------------------
§=.9900990099 (in 10 FIX mode),
which is exactly this:

http://www.wolframalpha.com/input/?i=sum_{i%3D1}^100+1%2F%28i*%28i%2B1%29%29

B. For infinite sums, you could use a program like this (which you
could name 'I§' or 'INF§'):

<<
0 0 -> ii Smnd
<<
{ STO ii Smnd } MENU HALT
Smnd 0 ii
DO
DUP 4 PICK EVAL
SWAP 1 +
ROT ROT OVER +
DUP 4 ROLLD
UNTIL ==
END ROT DROP2
23 MENU
DUP "§=" SWAP ->STR +
CLLCD 1 DISP
The final index is always +oo, so you don't have to supply an input
for fi.

Try this one:
ii = 1
Smnd = << -> X '1/X^4' >>
-------------------------------
§=1.08232323295

For comparison:
http://www.wolframalpha.com/input/?i=%28sum_{n%3D1}^%2Boo+1%2Fn^4%29

You can find a really excellent in-depth explanation of this topic in
"HP-28 Insights" by William C. Wickes, the very "creator" of the HP-28
(*and* HP-48) handheld computers. The core of my second program was
directly inspired by this book (p.254).

If you have any further questions, please feel free to ask.
c***@hotmail.com.ar
2012-02-12 04:51:39 UTC
Permalink
You can´t imagine how useful is your answer Giuseppe! Thank you very
much!!! I couldn´t be more grateful to you.
Giuseppe Donnini
2012-02-12 13:35:28 UTC
Permalink
You can´t imagine how useful is your answer Giuseppe!  Thank you very
much!!! I couldn´t be more grateful to you.
You are welcome!

Please bear in mind that constants are always treated as part of the
summand. For instance, for ii = 1, fi = 6 and Smd = << -> x 'x+5' >>,
§ yields 51, because 5 is treated as part of the summand and therefore
is added at each iteration: (1+5)+(2+5)+(3+5)+(4+5)+(5+5)+(6+5)=51. In
other words:

6 6
--- ---
n+5 is interpreted as: > (n+5) = 51
--- ---
n=1 n=1


Mathematica, however, will interpret this as:


/ 6 \
| --- |
| > n | + 5 = 26
| --- |
\ n=1 /

http://www.wolframalpha.com/input/?i=%28sum_{i%3D1}^6+i%2B5%29

So don't be fooled by this! Simply use parentheses in Mathematica to
obtain the same result:
http://www.wolframalpha.com/input/?i=%28sum_{i%3D1}^6+%28i%2B5%29%29
Giuseppe Donnini
2012-02-12 23:05:50 UTC
Permalink
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.
c***@hotmail.com.ar
2012-02-13 01:44:45 UTC
Permalink
Post by Giuseppe Donnini
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 '§' (§
<<
   -> 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
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
'§(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
'15+§(n,1,10,n^2)' EVAL => 400
       ________________
      /        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
<<
   -> 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
3: name of index variable
2: initial value of index
1: summand
'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}]
'\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.
Awesome! Thank you very much!
Giuseppe Donnini
2012-02-13 22:30:18 UTC
Permalink
You can even make plots, if you like:

A. For finite sums, store the following program in the variable
'§PLT':

(like in my previous listings, § represents the Greek letter sigma
(Shift+V))

<<
CLLCD
-> v ii fi s
<<
'PPAR' PURGE
CL§
1 2 COL§
"$="
'v' EVAL ->STR
DUP SIZE 1 - 2 SWAP SUB "=" +
0 ii fi
FOR x
x 'v' EVAL STO s EVAL +
x DUP2
->STR 5 PICK SWAP + 2 DISP
->STR 5 PICK SWAP + 1 DISP
OVER 2 ->ARRY §+
NEXT "STARTING PLOTTER..." 4 DISP 3 WAIT
SWAP ROT DROP2 'v' EVAL PURGE
SCL§ CLLCD DRW§ DGTIZ
To run the program, put the following 4 arguments on the stack and
press §PLT:


4: name of index variable
3: initial value of index variable
2: final value of index variable
1: summand, expressed as an ordinary algebraic (for example: 'n^2')

In a first phase, the program will display both the running index and
the running sum, so you can easily monitor the sum as it accumulates.

When the calculations are done, the screen is cleared and the
corresponding plot is drawn. (Naturally, this will create, or modify,
the reserved variables PPAR, §DAT and §PAR in the current directory.)

In the plot environment:
Press and hold down the <^v> key to display the current coordinates.
Press INS to return the current pair of coordinates to the stack.
Press ON to return to the stack.

When you quit the plot environment, the calculated sum will be
available on the stack for further calculations.

Optionally you can press §DAT (in the current directory) SHIFT+EDIT,
and you will see a nice table of values, with the index values in the
first column and the corresponding sums in the second.

Try this one, for instance:

4: 'n'
3: 1
2: 65
1: 'n^7/2^n'

§PLT

...and compare: http://www.wolframalpha.com/input/?i=%28sum_{n%3D1}^50+n^7%2F2^n%29

In the Plot environment, press ON to return to the stack (notice that
the result 94586 is preserved fot further calculations), then press
$DAT SHIFT+EDIT to see the corresponding table of values.


B. For infinite sums, store the following program in the variable
'I§PLT':

<<
CLLCD
-> v ii s
<<
'PPAR' PURGE
CL§
1 2 COL$
"$=" s 0 ii
DO
DUP 'v' EVAL STO
3 PICK EVAL
3 PICK +
SWAP DUP 1 +
4 ROLLD OVER 2 ->ARRY §+
DUP ->STR 6 PICK SWAP + 1 DISP
DUP 4 ROLLD
UNTIL ==
END "STARTING PLOTTER..." 3 DISP 3 WAIT
ROT DROP2 SWAP DROP 'v' EVAL PURGE
SCL§ CLLCD DRW§ DGTIZ
Since the final index value is +oo, I§PLT takes only 3 arguments:

3: name of index variable
2: initial value of index variable
1: summand

For the same reason, no running index is shown in the first phase of
the program (only the running sum).

Here is an example:

3: 'X'
2: 3
1: 'X^2/2^X'

I§PLT

For comparison: http://www3.wolframalpha.com/input/?i=%28sum_{n%3D3}^%2Boo+n^2%2F2^n%29
c***@hotmail.com.ar
2012-02-15 22:41:57 UTC
Permalink
Post by Giuseppe Donnini
A. For finite sums, store the following program in the variable
(like in my previous listings, § represents the Greek letter sigma
(Shift+V))
<<
   CLLCD
   -> v ii fi s
   <<
     'PPAR' PURGE
     CL§
     1 2 COL§
     "$="
     'v' EVAL ->STR
     DUP SIZE 1 - 2 SWAP SUB "=" +
     0 ii fi
     FOR x
         x 'v' EVAL STO s EVAL +
         x DUP2
         ->STR 5 PICK SWAP + 2 DISP
         ->STR 5 PICK SWAP + 1 DISP
         OVER 2 ->ARRY §+
     NEXT "STARTING PLOTTER..." 4 DISP 3 WAIT
     SWAP ROT DROP2 'v' EVAL PURGE
     SCL§ CLLCD DRW§ DGTIZ
   >>
To run the program, put the following 4 arguments on the stack and
4: name of index variable
3: initial value of index variable
2: final value of index variable
1: summand, expressed as an ordinary algebraic (for example: 'n^2')
In a first phase, the program will display both the running index and
the running sum, so you can easily monitor the sum as it accumulates.
When the calculations are done, the screen is cleared and the
corresponding plot is drawn. (Naturally, this will create, or modify,
the reserved variables PPAR, §DAT and §PAR in the current directory.)
Press and hold down the <^v> key to display the current coordinates.
Press INS to return the current pair of coordinates to the stack.
Press ON to return to the stack.
When you quit the plot environment, the calculated sum will be
available on the stack for further calculations.
Optionally you can press §DAT (in the current directory) SHIFT+EDIT,
and you will see a nice table of values, with the index values in the
first column and the corresponding sums in the second.
4: 'n'
3: 1
2: 65
1: 'n^7/2^n'
§PLT
...and compare:http://www.wolframalpha.com/input/?i=%28sum_{n%3D1}^50+n^7%2F2^n%29
In the Plot environment, press ON to return to the stack (notice that
the result 94586 is preserved fot further calculations), then press
$DAT SHIFT+EDIT to see the corresponding table of values.
B. For infinite sums, store the following program in the variable
<<
   CLLCD
   -> v ii s
   <<
     'PPAR' PURGE
     CL§
     1 2 COL$
     "$=" s 0 ii
     DO
        DUP 'v' EVAL STO
        3 PICK EVAL
        3 PICK +
        SWAP DUP 1 +
        4 ROLLD OVER 2 ->ARRY §+
        DUP ->STR 6 PICK SWAP + 1 DISP
        DUP 4 ROLLD
     UNTIL ==
     END "STARTING PLOTTER..." 3 DISP 3 WAIT
     ROT DROP2 SWAP DROP 'v' EVAL PURGE
     SCL§ CLLCD DRW§ DGTIZ
   >>
3: name of index variable
2: initial value of index variable
1: summand
For the same reason, no running index is shown in the first phase of
the program (only the running sum).
3: 'X'
2: 3
1: 'X^2/2^X'
I§PLT
For comparison:http://www3.wolframalpha.com/input/?i=%28sum_{n%3D3}^%2Boo+n^2%2F2^n%29
Amazing! You are an expert! Thanks

Loading...