Saturday, May 13, 2023

HP 12C Using TVM variables as Registers

 HP 12C Using TVM variables as Registers



Special Thanks

Regarding the HP 12C Tips talk I gave on HHC 2017, I received this tip from an email from   SergioSamy.   Appreciation and gratitude.  


To watch my HP 12C tip presentation, click here:

https://www.youtube.com/watch?v=Q54UbDzpAIw




Why Use TVM Variables?


Normally, we use the variables n, i, PV, PMT, and FV for time value of money, cash flow, and depreciation calculations.  They can be used for variables for non-finance or other business calculations as well.


When we program on the Classic HP 12C, we have 99 steps.  If the program memory is clear, we have 20 registers from R.9  (register dot-nine) to R0 (register zero).   For every eight steps, a memory register is lost.   


At full capacity of the Classic HP 12C, we only have seven registers left (R0 through R6).  


The moment that we use press the [ Σ+ ] button and use statistics, the registers R1 and R6 get occupied, possibly leaving R0 to use for other purposes:


R1 = n

R2 = Σx

R3 = Σx^2

R4 = Σy

R5 = Σy^2

R6 = Σxy


However, the TVM registers: n, i, PV, PMT, and FV, are permanent memory registers for use.   Today's programs will illustrate this use.   


Note:  Pressing the TVM keys once after a number (key word: after) stores the number in a variable.   If you don't key a number first, then the program solves for the a variable.  Let's look at a couple of examples.



Economic Ordering Quantity


Formula:


EOQ = √(2 * CPO * SLS ÷ (CPU * HOLD%))


CPO = fixed order cost

SLS = number of project sales units

CPU = variable cost per unit

HOLD% = projected cost of holding inventory

EOQ = economic ordering quantity, in units


TVM variables used:


[ n ]:  EOQ, computed

[ i ]: HOLD%,  entered

[ PV ]:  CPU, entered

[ PMT ]:  CPO, entered

[ FV ]:  SLS, entered



Program Code:


Line Number:  Key Code;  Key


01:  45, 14;  RCL PMT

02:  45, 15;  RCL FV

03:  20;  ×

04:  2;  2

05:  20;  ×

06:  45, 13;  RCL PV

07:  45, 12;  RCL i

08:  25;  %

09:  34;  x<>y

10:  33;  R↓

11:  10;  ÷

12:  43, 21;  √

13:  44, 11;  STO n

14:  43,33,00;  GTO 00



Example


CPO = 40.95

SLS = 8,000

CPU = 5.50

HOLD% = 10%


10 [ i ]

5.50 [ PV ]

40.95  [ PMT ]

8000 [ FV ]

[ R/S ].  Result:  1091.45


Source


HP-17B, HP-19B, HP-27S  Step-by-Step Solutions For Your HP Calculator.  Marketing and Sales.   Hewlett Packard.  Edition 1.  January 1988



Quadratic Equation


Instructions:


Find the roots of a*x^2 + b*x + c = 0


The program ends with the discriminant stored in R0. 


D = b^2 - 4*a*c


If D<0, the roots are complex in the form of s ± ti:

s:  real part, stored in PMT

t:  imaginary part, stored in FV


If D≥0, the roots are real and:

Root 1 is stored in PMT

Root 2 is stored in FV


Store a in [ n ], b in [ i ], and c [ PV ].  Then run the program. 


Note:  to get the absolute value, square then take the square root of the number.  This is why I have two square root commands in a row: one is to make the absolute value; the second to take the square root of D. 


Program Code:


Line Number:  Key Code;  Key


01:  45,12;  RCL I

02:  2;  2

03:  21;  y^x

04:  45, 13;  RCL PV

05:  45, 11;  RCL n

06:  20;  ×

07:  4;  4

08:  20;  ×

09:  30;  -

10:  44, 0;  STO 0

11:  45, 12;  RCL i

12:  16;  CHS

13:  2;  2

14:  10;  ÷

15:  45, 11;  RCL n

16:  10;  ÷

17:  44, 14;  STO PMT

18:  45, 0;  RCL 0

19:  2;  2

20:  21;  y^x

21:  43, 21;  √

22:  43, 21;  √

23:  2;  2

24:  10;  ÷

25:  45, 11;  RCL n

26:  10;  ÷

27:  44, 15;  STO FV

28:  0;  0

29:  45, 0;  RCL 0

30:  43, 34;  x≤y

31:  43,33,00;  GTO 00

32:  45,14;  RCL PMT

33:  36;  ENTER

34:  36;  ENTER

35:  45, 15;  RCL FV

36:  30;  -

37:  44, 15; RCL FV

38:  33; R↓

39:  43, 36;  LSTx

40:  40;  +

41:  44,14; STO PMT

42:  45, 0;  RCL 0

43:  43,33,00;  GTO 00


Examples


2*x^2 - 3*x + 6 = 0


2 [ n ]

-3 [ i ] 

6 [ PV ]

[ R/S ]


Results:

D = -39.00   (complex roots)

[ RCL ] [ PMT ]:  Real part:  0.75

[ RCL ] [ FV ]:  Imaginary part:  1.56

0.75 ± 1.56i


x^2 + 8*x - 4 = 0


1 [ n ]

8 [ i ] 

-4 [ PV ]

[ R/S ]


Results:

D = 80

[ RCL ] [ PMT ]:  Root 1:  0.47

[ RCL ] [ FV ]:  Root 2:  -8.47

0.47, -8.47



Hope you find this tip helpful,


Eddie 



All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.