Presentation is loading. Please wait.

Presentation is loading. Please wait.

Edward Shore, HHC 2017 September 2017

Similar presentations


Presentation on theme: "Edward Shore, HHC 2017 September 2017"— Presentation transcript:

1 Edward Shore, HHC 2017 September 2017
Expanding the HP 12C Edward Shore, HHC 2017 September 2017

2 Objectives To expand the HP 12C beyond the basic and financial capabilities Mathematical Tips and Tricks for the HP 12C Applications

3 Assumptions The regular/classic version of the HP 12C is used instead of the Platinum Edition 99 programming steps vs. 400 programming steps Always RPN vs. RPN/ALG setting Two digit vs. Three digit step markers LST X Code (43, 36 vs. 43, 40) No trigonometric functions are used Fix 2 Mode (round everything to 2 decimal places) is set

4 Other Sources Polynomial Solver Polynomials: Valentin Abillo
Trig Functions Trigonometric Functions: Valentin Abillo

5 Quick Mathematical Tips

6 Arithmetic Multiplying by 100: [ENTER], 1, [x<>y], [%T] One key stroke less than [ENTER], 1, 0, 0, [ * ] Dividing by 100: [ENTER], 1, [ % ] Two key strokes less than [ENTER], 1, 0, 0, [ ÷ ]

7 Mathematical Functions
Absolute Value: 2, [y^x], [ g ] ( √ ) Sign Function: [ENTER], [ENTER], 2, [y^x], [ g ] ( √ ), [ ÷ ] Modulus of two positive numbers (a mod b): a, [ENTER], b, [ ÷ ], [ g ] (LSTx), [ x<>y ], [ g ] (FRAC), [ * ]

8 Mathematical Functions
Number of Digits of an integer: [ g ] (LN), [EEX], 1, [ g ] (LN), [ ÷ ], [ g ] (INTG), 1, [ + ]

9 Keying in π The HP 12C does not have a π button, we’ll have to enter π manually or use an approximation. Using the 10 digit approximation This will take 11 steps, one for each digit and the decimal point. We can use the approximation π ≈ 355/113. 355/113 = (to 5 decimal places) This takes 8 steps: 3, 5, 5, ENTER, 1, 1, 3, ÷ Richard Nelson suggests this memory aid: take the first three odd digits twice (113355), divide last three by first three (355/113).

10 Example: Surface Area & Volume of Sphere
Step Code Key Notes 01 44, 0 STO 0 Store radius in R0 02 2 Calculate surface volume 03 21 Y^X 04 4 05 20 * 06 3 Enter π 07 5 08 09 36 ENTER 10 1 11 12 13 ÷ 14 15 31 R/S Display surface volume 16 Calculate volume 17 18 45, 0 RCL 0 19 43, 33, 00 GTO 00 Display volume, stop program execution

11 Number of Inputs Three ways to generate inputs:
Loading the stack before executing the program. This is useful when you have only one input. Prompt for the inputs using the [R/S]. Store all the required inputs in the registers before execution. This is my preferred method when I have 3 or more inputs.

12 Using x=0 to determine choices
You can designate a memory register, such as R0, as a choice variable. For example: Choice 0 executes function f(x) Choice 1 executes function g(x) And so on Depending on program size, 2 to 4 choices could fit within program memory. General algorithm: RCL R#, test value, -, x=0, GTO appropriate line number

13 Example – Choices: US to SI Unit Conversion
Step Code Key Notes 01 44, 0 STO 0 Store choice variable in R0 02 34 X<>Y 03 44, 1 STO 1 Store value to be converted in R1 04 05 43, 35 X=0 Conversion: lb to kg? 06 43, 33, 18 GTO 18 07 45, 0 RCL 0 Conversion: in to cm? 08 1 09 30 - 10 X=0? 11 43, 33, 27 GTO 27 12 Conversion: gal to L? 13 2 14 15 16 43, 33, 34 GTO 34 17 43, 33, 43 GTO 43 Conversion: mi to km? 18 45, 1 RCL 1 Conversion: lb to kg, flag = 0 19 20 48 .

14 Example – Choices: US to SI Unit Conversion
Step Code Key Notes 21 2 22 23 4 24 6 25 10 ÷ 26 43, 33, 00 GTO 00 27 45, 1 RCL 1 Conversion: in to cm, flag = 1 28 29 48 . 30 5 31 32 20 * 33 34 Conversion: gal to L, flag = 2 35 3 36 37 7 38 8 39 40

15 Example – Choices: US to SI Unit Conversion
Step Code Key Notes 41 20 * 42 43, 33, 00 GTO 00 43 45, 1 RCL 1 Conversion: mi to km, flag = 3 44 1 45 48 . 46 6 47 9 49 3 50 51

16 Use of Statistics Variables
We can use stat variables for additional analysis The cost is that six variables will be used (R1 to R6). This leaves only four variables for inputs and outputs (R0, R7, R8, R9) Statistics Variables R1: n R4: Σy R2: Σx R5: Σy^2 R3: Σx^2 R6: Σxy

17 Example – Simple Logistic Curve Fitting
This program uses the statistics variables, particularly Σx for R2 Curve: y = 1 / (A + B*e^(-x)) Transformation: X’ = e^(-X), Y’ = 1/Y

18 Example – Simple Logistic Curve Fitting
Step Code Key Notes 01 16 CHS Enter data 02 43, 22 e^x Adjust X: e^-x 03 34 x<>y 04 22 1/x Adjust Y: 1/y 05 06 49 Σ+ Enter data point, n is displayed 07 43, 33, 00 GTO 00 Stop program execution 08 Calculate b 09 43, 2 y^ 10 44, 7 STO 7 11 31 R/S Display b 12 1 Calculate m 13 14 15 33 R↓ 17 30 - 18 44, 8 STO 8 19 Display m

19 Simulating Subroutines
The HP 12C does not have subroutine commands, but you can simulate subroutines. Here is one way to do it, if you know the subroutine will be used twice: It is very important you plan your program in advance, with line numbers. Marking the line numbers will facilitate where the subroutine and return markings will be located.

20 Simulating Subroutines
Designate a register as a flag variable. Store 1 in the flag variable. Enter the main portion of the program. Determine where the subroutine will be called. Follow the subroutine call with the roll down command (R↓). At the end of the subroutine, recall the flag variable. Determine which round it is by recalling the flag variable. First round: flag = 1. Second round: flag = 0. Use the test x=0. If it passes, send the pointer to the second R↓. If it fails, subtract 1 from the flag variable and send the pointer to the first R↓.

21 Subroutine Example: Derivative Approximation
Step Key Code Notes 01 44, 0 STO 0 Store x in R0 02 1 03 44, 3 STO 3 Set up flag variable, 2 subroutine rounds 04 05 26 EEX 06 5 07 16 CHS 08 44, 1 STO 1 Store h in R1 09 45, 0 RCL 0 10 45, 1 RCL 1 11 40 + x+ h 12 43, 33, 23 GTO 23 Subroutine: 1st round 13 33 R↓ Return: 1st round 14 44, 2 STO 2 Store temp result, f(x + h) 15 x Subroutine: 2nd round 17 18 44, 30, 2 STO- 2 f(x+h) – f(x) 19 45, 2 RCL 2 20

22 Subroutine Example: Derivative Approximation
Step Key Code Notes 21 10 ÷ (f(x+h) – f(x))/h 22 43, 33, 00 GTO 00 Stop execution 23 36 ENTER Subroutine begins here, f(x) 24 25 2 26 Y^X 27 34 X<>Y 28 43, 22 e^x 29 20 * End of f(x) 30 45, 3 RCL 3 Need the next 7 steps to the end of f(x) – Check flag variable 31 43, 35 X=0 32 43, 33, 17 GTO 17 Are we in round 2? 33 1 If yes, go to 2nd return point 44, 30, 3 STO- 3 Otherwise, decrease flag variable 35 R↓ Set up display 43, 33, 13 GTO 13 Go to 1st return point

23 Additional Examples

24 Quadratic Equation Step Code Key Notes 01 45, 2 RCL 2
Start with values stored in R1, R2, R3. Calculate discriminant. 02 36 ENTER 03 20 * 04 45, 1 RCL 1 05 45, 3 RCL 3 06 07 4 08 09 30 - 10 44, 0 STO 0 11 31 R/S Display discriminant which is stored in R0. 12 13 43, 34 X≤Y Is 0 ≤ R0? 14 43, 33, 32 GTO 32 If so, go to step 32. 15 Complex Roots: real part 16 17 40 + 18 19 CHS

25 Quadratic Equation Step Code Key Notes 20 34 X<>Y 21 10 ÷ 22
21 10 ÷ 22 44, 4 STO 4 23 31 R/S 24 43, 36 LSTx Complex Roots: imaginary part 25 45, 0 RCL 0 26 16 CHS 27 43, 21 28 29 30 44, 5 STO 5 43, 33, 00 GTO 00 Stop execution 32 45, 2 RCL 2 Real root calculations 33 35 36 40 + 37 45, 1 RCL 1 38 ENTER 39

26 Quadratic Equation Step Code Key Notes 40 10 ÷ 41 44, 4 STO 4 42 31
41 44, 4 STO 4 42 31 R/S Real root 1 43 43, 36 LSTx 44 45, 2 RCL 2 45 45, 0 RCL 0 46 43, 21 47 + 48 16 CHS 49 34 X<>Y 50 51 44, 5 STO 5 52 43, 33, 00 GTO 00 Real root 2

27 Greatest Common Divisor
Step Code Key Notes 01 43, 34 X≤Y Determine which integer is greater 02 34 X<>Y 03 44, 1 STO 1 R1 = max(X,Y) 04 05 44, 0 STO 0 R0 = min(X,Y) 06 45, 1 RCL 1 Begin Euclidian division routine 07 Recall R1 twice 08 45, 0 RCL 0 09 10 ÷ Divide R1 by R0 43, 25 INTG int(R1/R0) 11 12 20 * 13 30 - Calculate remainder: remainder = int(R1/R0) * R0 – R1 14 43, 35 X=0 Is remainder = 0? 15 43, 33, 21 GTO 21 If yes, go to the end 16 If not, set up for the next loop 17 Old min becomes new max, R0 → R1

28 Greatest Common Divisor
Step Code Key Notes 18 34 X<>Y 19 44, 0 STO 0 Store new min 20 43, 33, 06 GTO 06 Start Euclidian division routine again 21 45, 0 RCL 0 End Result: display GCD 22 43, 33, 00 GTO 00 Stop execution

29 Binary to Decimal Conversion
Step Code Key Notes 01 44, 0 STO 0 Store the binary integer, assume no sign bit 02 43, 23 LN Determine the number of digits 03 26 EEX 04 1 05 06 10 ÷ 07 43, 25 INT 08 09 40 + 44, 2 STO 2 Store number of digits in R2 11 Initialize decimal conversion, store 0 in R1 12 44, 1 STO 1 13 44, 3 STO 3 14 45, 0 RCL 0 Conversion process 15 45, 3 RCL 3 16 17 18 19

30 Binary to Decimal Conversion
Step Code Key Notes 20 34 X<>Y 21 Y^X 22 10 ÷ 23 43, 24 FRAC 24 26 EEX 25 1 * 27 43, 25 INTG 28 2 29 36 ENTER 30 45, 3 RCL 3 31 32 33 44, 40, 1 STO+ 1 35 44, 40, 3 STO+ 3 Determine the number of digits left to work with

31 Binary to Decimal Conversion
Step Code Key Notes 37 45, 2 RCL 2 38 30 - 39 43, 35 X=0 40 43, 33, 42 GTO 42 41 43, 33, 14 GTO 14 42 45, 1 RCL 1 Display decimal integer 43 43, 33, 00 GTO 00

32 Thank you! Any questions?


Download ppt "Edward Shore, HHC 2017 September 2017"

Similar presentations


Ads by Google