Newsgroups: comp.sys.hp48

Jeff Orchard writes:
>>I want to pass a function into a program that uses the integrator.
>>I know how to pass things into local variables, but in order to
>>numerically integrate the function it seems to me that I
>>can't just pass 'F'; I have to pass 'F(X)' (so that I can integrate
>>with respect to X).
>>
>>I would like to be able to put 'F' in level 1 and then execute the
>>program.  I DON'T want to have to put 'F(X)' on the stack... because that
>>would force me to integrate with respect to X.  It would be nice if
>>I could integrate with respect to a local variable.
>>
>>OR... my problems would be solved if I could change this... "F(X)"
>>to this... 'F(X)'
>>
>>Any ideas would be appreciated.  Thanks!
>>
>>Jeff Orchard	jorchard@dretor.dciem.dnd.ca
>>

This was exactly the capability provided with the HP28's version
of integration. Fortunately for most people, the '48's version
of integration is allowed within expressions. Unfortunately, function
definitions cannot be directly embedded in expressions. 

Given below are work-arounds (for both numeric and symbolic integration)
in the case 1) a function definition is provided or case 2) the name
of a function is provided. They are given as recorded dialog with
a '48 in Kermit server mode (ASCII, translate mode 3). The function
given as an example is x -> x^2. In the numeric case, we bind the
function to a local variable ('F' in the examples) and numerically
integrate F(x)dx. In the symbolic case, we apply the function to
a quoted local variable ('y' in the examples) and integrate the
result with respect to y.

remote host \"Case 1: Fcn on stack
1: "Case 1: Fcn on stack"

remote host \\<< \\-> x \'x^2\' \\>>
2: "Case 1: Fcn on stack"
1:         \<< \-> x 'x^2' \>>

remote host \"Numeric:
3: "Case 1: Fcn on stack"
2:         \<< \-> x 'x^2' \>>
1:         "Numeric:"

remote host OVER
4: "Case 1: Fcn on stack"
3:         \<< \-> x 'x^2' \>>
2:         "Numeric:"
1:         \<< \-> x 'x^2' \>>

remote host \\<< \\-> F \\<< \'\\.S(0,3,F(x),x)\' \\->NUM \\>>
5: "Case 1: Fcn on stack"
4:         \<< \-> x 'x^2' \>>
3:         "Numeric:"
2:         \<< \-> x 'x^2' \>>
1: \<< \-> F \<< '\.S(0,3,F(x),x)' \->NUM \>> \>>

remote host EVAL
4: "Case 1: Fcn on stack"
3:         \<< \-> x 'x^2' \>>
2:         "Numeric:"
1:                     9

remote host \"Symbolic:\"
5: "Case 1: Fcn on stack"
4:         \<< \-> x 'x^2' \>>
3:         "Numeric:"
2:                     9
1:       "Symbolic:"

remote host 4 PICK
6: "Case 1: Fcn on stack"
5:         \<< \-> x 'x^2' \>>
4:         "Numeric:"
3:                     9
2:       "Symbolic:"
1:         \<< \-> x 'x^2' \>>

remote host \\<< 0 \\-> F y \\<< 0 \'X\' \'y\' F EVAL \'y\' \\.S \\>> \\>>
7: "Case 1: Fcn on stack"
6:         \<< \-> x 'x^2' \>>
5:         "Numeric:"
4:                     9
3:       "Symbolic:"
2:         \<< \-> x 'x^2' \>>
1: \<< 0 \-> F y \<< 0 'X' 'y' F EVAL 'y' \.S \>> \>>

remote host EVAL
6: "Case 1: Fcn on stack"
5:         \<< \-> x 'x^2' \>>
4:         "Numeric:"
3:                     9
2:       "Symbolic:"
1: 'y^(2+1)/((2+1)*\.dy(y))|(y=X)-(y^(2+1)/((2+1)*\.dy(y))|(y=0))'

remote host EVAL
6: "Case 1: Fcn on stack"
5:         \<< \-> x 'x^2' \>>
4:         "Numeric:"
3:                     9
2:       "Symbolic:"
1:               'X^3/3'

remote host \"Case 2: Name on stack\"
7: "Case 1: Fcn on stack"
6:         \<< \-> x 'x^2' \>>
5:         "Numeric:"
4:                     9
3:       "Symbolic:"
2:               'X^3/3'
1: "Case 2: Name on stack"

remote host 6 PICK \'G\' STO \'G\'
8: "Case 1: Fcn on stack"
7:         \<< \-> x 'x^2' \>>
6:         "Numeric:"
5:                     9
4:       "Symbolic:"
3:               'X^3/3'
2: "Case 2: Name on stack"
1:                   'G'

remote host \\<< \\-> F \\<< F RCL \"now revert to case 1\" \\>> \\>>
9: "Case 1: Fcn on stack"
8:         \<< \-> x 'x^2' \>>
7:         "Numeric:"
6:                     9
5:       "Symbolicalyy:"
4:               'X^3/3'
3: "Case 2: Name on stack"
2:                   'G'
1: \<< \-> F \<< F RCL "now revert to case 1" \>> \>>

remote host EVAL
9: "Case 1: Fcn on stack"
8:         \<< \-> x 'x^2' \>>
7:         "Numeric:"
6:                     9
5:       "Symbolic:"
4:               'X^3/3'
3: "Case 2: Name on stack"
2:         \<< \-> x 'x^2' \>>
1: "now revert to case 1"