HP48G Message #1 Posted by Viktor T. Toth on 8 Jan 2010, 8:56 p.m.
I am playing with a newly acquired HP48G as I write this and it
keeps me amazed. Other
machines may have gimmicks like a color display, but in terms of
functionality, the HP48
series is far superior to anything I've ever seen. Just as keystroke
programmable
calculators were a perfect learning tool for the programmer of the 70s
or the early 80s,
this machine with its objectoriented User RPL language is the perfect
learning tool for
the 90s and beyond. But it's more than just a learning tool: all HP48
calculators are
serious professional instruments.
To demonstrate this, I decided to do something different. For the
majority of
calculators shown on this Web site (with the exception of a few very
lowend machines that
don't support this) the programming example I present is an
implementation of the Gamma
function. For the HP28/48 series of calculators, I have
already presented a complex
implementation of this function, and an implementation of the incomplete
Gamma function
as well. There are only so many variations on a theme!
Fortunately, just a few days ago I was able to assist someone on the
Internet with an
HP48 programming question, and it gave me the opportunity to practice
my RPL programming
skills. The question was this: how do you create a program that
calculates the radius of
curvature? For any function f(x), the radius of curvature at
any x=x_{0}
can be obtained by evaluating (1+(f'(x)^{2}))^{3/2}/f''(x).
So, can we create a program that takes a number (x_{0})
and a function as arguments on the stack, and returns a number
that's the value
of the radius of curvature we seek?
Few programming languages offer such a powerful feature (in fact, the
only nonHP
machines that I know about that are capable of this feat are the TI89
and TI92).
Were we to
use C++, we would be forced to write a sophisticated expression
evaluator (or
alternatively, we would have to resort to using a third party library.)
Not so with User
RPL, as the program below neatly demonstrates.
To use this program, enter an expression using an independent
variable, the name of the
independent variable, a value. For instance, enter the following
arguments:
'X^3'
'X'
2
When you invoke the program (I stored it under the name ROC
on my
calculator) within a couple of seconds, the display will show the
result: 145.50260116.
You can also use ROC in algebraic expressions (e.g., 'ROC(X^3,X,2)').
Please note that using this program requires that your calculator be
placed in symbolic
mode (3 CF). For this reason, you
cannot use >NUM
on expressions containing ROC, nor can you use ROC
as a
plot function without writing a suitable wrapper function.
«
> fX x x0
«
fX x ∂ DUP > dfX
«
dfX x ∂
»
SWAP 2 ^ 1 + 3 ^ √ SWAP / > fR
«
fR x x0 2 >LIST 
»
»
»
