Hi all:
-
The recent release of the HP-15C LE is a momentous event which truly deserves a great celebration on my part, being as I am a life-long sworn fan of this wonderful model (most especially today which is the one-and-only 11-11-11 date you'll get to see for the next 100 years or so).
- first and foremost, it must be as short as possible, anything more than a dozen steps or two means back to the drawing board for you. The program must begin with LBL A and end with RTN.
- it must accept a given real ordinate X in the display and produce the value of the derivative of y(x) at that ordinate, where y(x) is a user-supplied function which must be accessible under LBL E.
- it must not depend on or require any particular setting or any particular memory allocation to be previously stablished.
- it must not require any pre-stored constants in the registers or stack contents except for the ordinate X being initially in the display at runtime.
- and last but not least, it must strive to produce full 10-digit accuracy (except for the usual cases of particular troublesome points or ranges, etc, of course).
However, as I'm currently not in the mood for any great efforts and I'm feeling a little lazy today, methinks you'll have to make do with this two-bit
HP-15C (& LE!) 11-11-11 Mini-Challenge
We all know that numerical integration is all the rage these days in the forum with plenty of good algorithms being discussed and offered for consideration to the WP34S team and such. The best of those integration algorithms are powerful and complex, a many-byte affair.
However, on the other hand, the ugly duckling would be numerical derivation which, unlike integration, can usually be done by numerically evaluating a symbolically-obtained derived function y'(x) at any specified X ordinate. Regrettably, that requires some advanced symbolic manipulation which is simply unavailable in the HP-15C (&LE!) and thus numerical approximations is the only way to go.
So the challenge is:
You're asked to write a program for the HP-15C (& LE!) which must be as short as possible, and which can evaluate the derivative at a given ordinate X of a user-supplied function y(x), subject to the following mandatory requirements.
The exact requirements your program must meet are:
Sample of use:
- given y(x) = ex/Sqrt(sin(x)3+cos(x)3), find y'(1.5)
define y(x) -> LBL E, e^X, LAST X, LAST X, SIN, 3, y^x, X<>Y, COS, 3, y^x, +, SQR, /, RTN
1.5, GOSUB A -> 4.053427894, which is the correct result to all 10 digits
- given y(x) = 7*e(2.1*X), find y'(15)
define y(x) -> LBL E, 2.1, *, e^X, 7, *, RTN
15, GOSUB A -> 7.040338081 E14, which is the correct result to all 12 digits
- given y(x) = sin(x)/ex, find y'(1)
define y(x) -> LBL E, SIN, LAST X, e^X, /, RTN
1, GOSUB A -> -0.1107937653, whis is correct to all 10 digits
Within a few days I'll post my solution, which is just 11 steps long, meets all five conditions above, and produces the sample results above correct to all digits shown. Relaxing a condition or two could shorten it even further, to just 6 steps or even just 5, but let's first keep all five requirements above and see what YOU can produce ... :)
Enjoy !
Best regards from V.
.