Thursday, February 26, 2015

Throwback Thursday: Programs for the HP 49g+/50g from 2003-2007

Throwback Thursday:  Programs for the HP 49g+/50g from 2003-2007

My first Hewlett Packard calculator was an HP 48G+, which I bought in 2000.  I really did not get serious into RPN and RPL until I bought an HP 49g+ in 2003.  Despite keyboard problems, the 49g+ was my go-to calculator.   The first 49g+ had a plus key that came loose, the second one I had trouble with the ON button.  Thankfully, by the time the HP 50g was released, the keyboard was reliable.  I bought my first 50g I think in 2003 – not sure.  It was the standard black 50g with orange and white text. Several years later, I ordered the blue 50g from Spain.  Recently, I traded the black 50g with a friend of mine (me getting a HP 42S in return). 

During 2003 to 2006 (I wish I noted the dates when I programmed these things back then), I made a library of programs that covered math, science, finance, and stats.  After finding them still on the SD card, today, I am going to list some of my favorite programs from that era. 

All the programs presented were done in User RPL and most of them, if not all of them, should be able to be used on any of the HP 48 series.  (no guarantees)

QCKPLOT – Simplified Plot Screen
(updated 2/19/2015)

QCKPLOT is probably my favorite out of the bunch.  QCKPLOT allows the user to plot a single function y(x) in a familiar graph set up screen input interface.  The plotting interface with the 49g+ and 50g took a while to get used to. 



QCKPLOT:
<< ‘X’ PURGE
“Quick Function Plot” 
{ { “y(x)=” “Enter y(x)” }
{ “xmin=” “x minimum” }
{ “xmax=” “x maximum” }
{ “ymin=” “y minimum” }
{ “ymax=” “y maximum” } }
{ 2 2 } { } { } INFORM
IF 0 == THEN KILL END
EVAL YRNG XRNG STEQ ‘X’ INDEP FUNCTION (0,0) AXES
ERASE DRAX DRAW PICT {#0d #0d} “Y=” EQ →STR + 1
→GROB GOR PICTURE >>

You can use RPN to build expressions.  However, everything for the window variables must evaluate to numbers.  For example, if you want to set xmax to 2π, use 2 π * →NUM [ENTER].  Which brings me to my next favorite…

PCTXT:  Puts text on the graph screen.

PCTXT inserts a text screen to any Cartesian point on the graph screen.  The program does not immediately show the graph screen upon completion, which allows for use as a subroutine.  If PCTXT is used a standalone program, press the left arrow button [ ← ] or hold [left shift] while pressing [ F3 ] to see the results. (I am assuming you are in RPN mode).

Input:
2:  coordinates
1:  string

PCTXT:
<< 1 →GROB PICT ROT C→PX ROT GXOR >>

ZETA41:  Zeta Function Approximation

The HP 49g+/50g does not have a built in Reimann Zeta function.  Using the standard definition of the zeta function takes forever.

Σ(I=1, infinity, 1/X^Z)

 What is presented here is a series that converges faster than the standard definition. The upper limit of 250 is arbitrary – you can increase the upper limit for better accuracy, but keep in mind it there is a cost in calculation time. The accuracy increases as X increases.

Input:
1:  X

ZETA41:
<< → X ‘∑(I=1,250,(-1)^(I+1)/I^X)/(1-2^(1-X))’ >>

FIB:  nth Fibonacci Number

FIB uses an explicit formula to calculate the nth Fibonacci number, rather than use a sequence loop. 

Input:
1:  N

FIB:
<< → N
<< 1 5 √ + 2 / N ^ 1 5 √ - 2 / N ^
- 5 √ / EVAL 0 RND >> >>

Test:  FIB(8) = 21,  FIB(12) = 144

CRDTRN Subroutine:  (Coordinate Transformation)

CRDTRN transforms a coordinate (x, y) to a new coordinate (x’, y’) with new center (xc, yc) and rotation angle θ.  CRDTRN is both a good standalone program and a useful subroutine.

Input:
5:  XOLD
4:  YOLD
3:  XCTR
2:  YCTR
1:  θ

CRDTRN
<< → XOLD YOLD XCTR YCTR θ
<< XOLD YOLD R→C XCTR YCTR R→C – θ DUP COS →NUM SWAP NEG SIN →NUM R→C * >> >>

Example:  Let the original coordinate be (1,2)  What would be the coordinates if the center was moved to (-1, 3) and the plane was rotated 60⁰ (π/3 radians)?

In Raidian Mode:
5:  1
4:  2
3:  -1
2:  3
1:  π/3

New coordinate:  (.13397456215, -2.23205080757)

QUADRES:  Quadratic Regression (uses ∑DAT)
(Update 2/19/2015)

QUADRES aims to fulfill a missing statistical regression for the HP 49g+/50g series:  quadratic regression.

Y = a*X^2 + b*X + c

The program uses the standard system statistics matrix ΣDAT.  The coefficients are returned in a matrix:

[[ c ]
[ b ]
[ a ]]

Example:

ΣDAT =
[[ 2, .23 ]
[ 3, .58 ]
[ 4, .96 ]
[ 8 1.85 ]
[ 16 3.66 ]]

Results:
[[ -.302930140195 ]
[ .304114954514 ]
[ -3.55628308881E-3 ]]

Or Y = -3.55628308881E-3*X^2 + .304114954514*X - .302930140195

QUADRES:
<< ∑DAT 1 COL- VANDERMONDE DUP SIZE OBJ→ DROP DROP 3 2 →LIST {1,1}
SWAP SUB LSQ >>

CSUM:  Sum of each of the matrix’s columns
RSUM:  Sum of each of the matrix’s rows

An example for CSUM and RSUM:

Matrix:
[[ 2, 3, -7 ]
[ 1, 8, 1 ]
[ -3, 4, 6 ]]

CSUM: [0, 15, 0]
RSUM: [-2, 10, 7]

Input:  Matrix

CSUM:
<< →COL → S
<< 1 S START AXL ∑LIST S ROLL NEXT
S →LIST AXL >> >>

RSUM:
<< →ROW → S
<< 1 S START AXL ∑LIST S ROLL NEXT
S →LIST AXL >> >>

LVEVAL:  Evaluate (simplify) every element in a list or vector

LVEVAL evaluates and simplifies each component of a given list or vector.  For example, LVEVAL turns a list consisting of:

{‘e^2’, ‘π/2’, ‘5.273*LOG(3.44)’} to:

In exact mode:
{‘e^2’, ‘π/2’, 2.82927266768}

Or in approximate mode:
{7.38905609893, 1.5707963268, 2.82927266768}

Input:
1:  list/vector

LVEVAL:
<< → LV
<< LV TYPE 5 IF ≠
THEN LV AXL ‘LV’ STO 1 SF END 1 LV SIZE
FOR I LV I GET EVAL LV I 3 ROLL PUT ‘LV’
STO NEXT IF 1 FS? THEN LV AXL ‘LV’ STO 1
CF END LV >> >>



Bezier Curve

This program draws a Bezier curve.  I honestly don’t quite remember what α0, β0, α1, and β1 represent – I think they are points that are not on the curve be affect the path of the curve. (X0, Y0) and (X1, Y1) are end points. 


« 'T' PURGE PARAMETRIC { T 0. 1. } INDEP "Bézier Curve" { "X0" "Y0" "α0" "ß0" "X1" "Y1" "α1" "ß1" } { 2. 4. } { } { } INFORM 0.
  IF ==
  THEN KILL
  END OBJ→ DROP → X0 Y0 α0 ß0 X1 Y1 α1 ß1
  « X0 X1 - 2. * α0 α1 + 3. * + 'T' 3. ^ * X1 X0 - 3. * α1 α0 2. * + 3. * - 'T' 2. ^ * + α0 3. * 'T' * + X0 + Y0 Y1 - 2. * ß0 ß1 + 3. * + 'T' 3. ^ * Y1 Y0 - 3. * ß1 ß0 2. * + 3. * - 'T' 2. ^ * + ß0 3. * 'T' * + Y0 + i * + 'XY1(T)' SWAP = DEFINE 'T' XY1 STEQ 'T' XY1 ERASE AUTO DRAX DRAW PICTURE  »  »


One Minute Marvels

The document “One Minute Marvels” by Richard Nelson and Wlodek Mier-Jedrzejowicz is a collection of short, very effective RPL programs for the HP 48 series.  Programs include list operations (including rotate a list’s elements, fill a list with zeroes, randomize a list), calendar functions (including day of the week, stopwatch programs), and math and utility programs (LCD, GCM, Ulad Principle, quick quadratic equation, and flag toggles just to name a few).  For owners of the HP 48 series, including HP 49g+/50g, I consider this document an excellent addition to your mathematics library.

Link to download “One Minute Marvels”:  http://www.hpcalc.org/details.php?id=1691


Cheers to the HP 48 series and my trusty blue HP 50g!

Eddie



This blog is property of Edward Shore – 2015.

Spotlight: Sharp EL-5200

  Spotlight: Sharp EL-5200 As we come on the 13 th (April 16) anniversary of this blog, I want to thank you. Blogging about mathematic...