Message #1 Posted by Viktor T. Toth on 8 Jan 2010, 8:56 p.m.
I am playing with a newly acquired HP-48G as I write this and it
keeps me amazed. Other
machines may have gimmicks like a color display, but in terms of
functionality, the HP-48
series is far superior to anything I've ever seen. Just as keystroke
calculators were a perfect learning tool for the programmer of the 70s
or the early 80s,
this machine with its object-oriented User RPL language is the perfect
learning tool for
the 90s and beyond. But it's more than just a learning tool: all HP-48
serious professional instruments.
To demonstrate this, I decided to do something different. For the
calculators shown on this Web site (with the exception of a few very
low-end machines that
don't support this) the programming example I present is an
implementation of the Gamma
function. For the HP-28/48 series of calculators, I have
already presented a complex
implementation of this function, and an implementation of the incomplete
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
HP-48 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
can be obtained by evaluating (1+(f'(x)2))3/2/f''(x).
So, can we create a program that takes a number (x0)
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
machines that I know about that are capable of this feat are the TI-89
Were we to
use C++, we would be forced to write a sophisticated expression
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
When you invoke the program (I stored it under the name ROC
calculator) within a couple of seconds, the display will show the
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
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 |