Saturday, January 11, 2025

RPN with HP 15C & DM32: Solving Simple Systems

RPN with HP 15C & DM32: Solving Simple Systems


Welcome to another edition of RPN with HP 15C & DM32.


Many Approaches to a Solving Problems


This blog covers two ways to solve the simple linear system of two equations:


x + y = a

x – y = b


In matrix form:


[ [ 1, 1 ] [ 1, - 1] ] * [ [ x ] [ y ] ] = [ [ a ] [ b ]


The inverse of the coefficient matrix [ [ 1, 1 ] [ 1, - 1] ]:


[ [ 1, 1 ] [ 1, - 1] ] ^-1 = [ [ 0.5, 0.5 ] [ -0.5, 0.5 ] ]


[ [ x ] [ y ] ] = [ [ 0.5, 0.5 ] [ -0.5, 0.5 ] ] * [ [ a ] [ b ] ]


The solution to the system is:


x = (a + b) / 2

y = (a – b) / 2



As far as keying the solutions in the calculator, we can address this two ways. The first, and probably the easier method, is to use memory registers. The second is to use stack operations such as swap (x<>y), roll up (R↑), roll down (R↓), enter (ENTER) as duplication, and the Last X function (LST x). Both the HP 15C and DM32 use a four-level stack.



The Memory Register Approach


Start with the stack as follows:


Y: a

X: b

The results are presented as:


Y: y

X: x


Memory Registers used:


HP 15C: R1 = a, R2 = b

DM32: A, B


HP 15C Code:


001

42, 21, 11

LBL A

002

44, 2

STO 2

003

34

X<>Y

004

44, 1

STO 1

005

30

-

006

16

CHS

007

2

2

008

10

÷

009

45, 2

RCL 2

010

45, 40, 1

RCL + 1

011

2

2

012

10

÷

013

43, 32

RTN



DM32 Code (31 bytes):


T01 LBL T

T02 STO B

T03 x<>y

T04 STO A

T05 -

T06 +/-

T07 2

T08 ÷

T09 RCL B

T10 RCL + A

T11 2

T12 ÷

T13 RTN


The Stack Approach


Start with the stack as follows:


Y: a

X: b

The results are presented as:


T : original contents of the z stack

Z: original contents of the z stack

Y: y

X: x


This time no memory registers are used


HP 15C Code:


001

42, 21, 12

LBL B

002

40

+

003

43, 36

LST x

004

2

2

005

20

×

006

34

X<>Y

007

36

ENTER

008

33

R↓

009

30

-

010

16

CHS

011

2

2

012

10

÷

013

43, 33

R↑

014

2

2

015

10

÷

016

43, 32

RTN



DM32 Code (24 bytes):


S01 LBL S

S02 +

S03 LAST x

S04 2

S05 ×

S06 x<>y

S07 ENTER

S08 R↓

S09 -

S10 +/-

S11 2

S12 ÷

S13 R↑

S14 2

S15 ÷

S16 RTN



Examples


Example 1:

x + y = 32

x – y = 16


32 ENTER 16 (run program)


Results: y = 8, x = 24


Example 2:

x + y = 9

x – y = -8


Results: y = 8.5, x = 0.5



Until next time,


Eddie


All original content copyright, © 2011-2025. 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.

Saturday, January 4, 2025

Casio fx-CG 50: Pseudorandom Number Generator (PRNG) Stat Plot

Casio fx-CG 50: Pseudorandom Number Generator (PRNG) Stat Plot


Introduction


This program is an inspiration from a HHC 2024 talk given by Kuba Tatarkiewicz. Tatarkiewicz’s talk is about testing RNG (random number generators). You can see it here: https://www.youtube.com/watch?v=vSDfqCK-ENk



Premise of RANDGRPH: Generate a recursive sequence


r_n = frac( (A * r_n-1 + B) ^ C)


The program builds two lists and develops a scatter plot. I have the program set up to plot 60 points, but we can up to 999 points. The list starts with the initial point (0, seed). The program asks you whether to have the calculator provide the seed or you provide a seed (between 0 and 1).



Casio fx-CG 50 Code: RANDGRPH (252 bytes)


“RAN # GRAPH”

“(A×R+B)^C” ◢

“A”? → A

“B”? → B

“C”? → C

Menu “SEED?”, “RANDOM”, 1, “YOUR OWN”, 2

Lbl 1

Ran# → R

Goto 0

Lbl 2

“0≤R<1, SEED”? → R

Lbl 0

{0} → List 1

{R} → List 2

For 1 → I To 75

Augment(List 1, {R}) → List 1

Frac((A×R+B)^C) → R

Augment(List 2,{R}) → List 2

Next

S-Gph1 DrawOn, Scatter, List 1, List 2, 1, Dot, ColorLinkOff, Black, AxesOn

DrawStat



Examples


Example 1: r_n = frac(991 * r_n-1)


r_n = frac(991 * r_n-1)


Example 2: r_n = frac( (0.3 * r_n-1 + 1)^2 )


r_n = frac( (0.3 * r_n-1 + 1)^2 )


Example 3: r_n = frac( (r_n-1 + π)^5 )


r_n = frac( (r_n-1 + π)^5 )


Enjoy! Happy New Year, be safe, sane, strong, and take care. Forever grateful,


Eddie


All original content copyright, © 2011-2025. 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.

Saturday, December 28, 2024

TI-30Xa Algorithms: RLC Series Circuit

TI-30Xa Algorithms: RLC Series Circuit


The task is to calculate the total impedance and phase angle for an RLC circuit in a series. An RLC circuit contains a resistor ( R ), an inductor ( L ), and a capacitor ( C ) , all powered by a voltage supply. The resistor, inductor, and capacitor are all in a single path.


The three elements are measured in the following units:


Resistor ( R ): Ohms ( Ω )

Inductor ( L ): Henry ( H )

Capacitor ( C ): Farads ( F )


The RLC series circuit is a circuit that connects a power source to a resistor, inductor, and a conductor in one path.




The impedance triangle is an illustration of how the impedance of an RLC series circuit and phase angle are calculated.



The impedance for the RLC circuit is calculated by:

Z = √( R^2 + ( (2 * Ï€ * f * L) - 1 / (2 * Ï€ * f * C) )^2 )


The phase angle is calculated by:

θ = arctan( ( (2 * π * f * L) - 1 / (2 * π * f * C) ) / R )


where: f = frequency in Hertz (Hz)


We can use the rectangular to polar conversion function (R>P) to calculate both the impedance and phase angle.


x = R

y = (2 * π * f * L) - 1 / (2 * π * f * C)


If we have an RL circuit, with no capacitor, then C = 0.

If we have an RC circuit, with no inductor, then L = 0.

If we have an LC circuit, with no resistor, then R = 0.



TI-30Xa Algorithm – RLC Circuit


Step 1: Store resistance in Memory 1.

R [ STO ] 1


Step 2: Calculate angular frequency, ω = 2 * π * f, store in memory 3.

2 [ × ] [ Ï€ ] [ × ] f [ = ] [ STO ] 3


Step 3: Calculate (2 * π * f * L) - 1 / (2 * π * f * C)

[ RCL ] 3 [ × ] L [ - ] [ ( ] [ RCL ] 3 [ × ] C [ ) ] [ 1/x ] [ = ] [ STO ] 2


If we have an RL circuit, Steps 2 and 3 can be shortened to:

2 [ × ] [ Ï€ ] [ × ] f [ × ] L [ = ] [ STO ] 2


If we have an RC circuit, Steps 2 and 3 can be shortened to:

[ ( ] 2 [ × ] [ Ï€ ] [ × ] f [ × ] C [ ) ] [ 1/x ] [ +/- ] [ = ] [ STO ] 2


Step 4: Calculate Impedance and Phase Angle:

[ RCL ] 1 [ 2nd ] [ π ] (x<>y) [ RCL ] 2 [ 2nd ] [ - ] (R>P)


What is shown: (r) Impedance

Press [ 2nd ] [ π ] (x<>y) for phase angle (θ)


Examples




Example 1: RLC Series Circuit

R = 50 Ω

L = 3.8 H

C = 0.7 F

f = 40 Hz


Step 1: Store resistance in Memory 1.

50 [ STO ] 1


Step 2: Calculate angular frequency, ω = 2 * π * f, store in memory 3.

2 [ × ] [ Ï€ ] [ × ] 40 [ = ] [ STO ] 3 (251.3274123)


Step 3: Calculate (2 * π * f * L) - 1 / (2 * π * f * C)

[ RCL ] 3 [ × ] 3.8 [ - ] [ ( ] [ RCL ] 3 [ × ] 0.0007 [ ) ] [ 1/x ] [ = ] [ STO ] 2

(949.36000616)


Step 4: Calculate Impedance and Phase Angle:

[ RCL ] 1 [ 2nd ] [ π ] (x<>y) [ RCL ] 2 [ 2nd ] [ - ] (R>P)


Impedance: 950.6758262

Phase Angle: 86.9851854°



Example 2: RLC Series Circuit

R = 450 Ω

L = 1.15 H

C = 3.5 μF = 3.5 * 10^-6 F

f = 60 Hz


Step 1: Store resistance in Memory 1.

450 [ STO ] 1


Step 2: Calculate angular frequency, ω = 2 * π * f, store in memory 3.

2 [ × ] [ Ï€ ] [ × ] 60 [ = ] [ STO ] 3 (376.9911184)


Step 3: Calculate (2 * π * f * L) - 1 / (2 * π * f * C)

[ RCL ] 3 [ × ] 1.15 [ - ] [ ( ] [ RCL ] 3 [ × ] 3.5 [ EE ] 6 [ +/- ] [ ) ] [ 1/x ] [ = ] [ STO ] 2

(-324.3408952)


Step 4: Calculate Impedance and Phase Angle:

[ RCL ] 1 [ 2nd ] [ π ] (x<>y) [ RCL ] 2 [ 2nd ] [ - ] (R>P)


Impedance: 554.7044405

Phase Angle: -35.78246242°



Source


“Impedance and Complex Impedance” Electronics Tutorials. AspenCore, Inc. 2024. Retrieved October 7, 2024. https://www.electronics-tutorials.ws/accircuits/impedance.html



This wraps up the TI-30Xa Algorithm Series. Next up will be a series on the Casio fx-991CW.


I want to wish you all a Happy New Year and a prosperous, sane, and happy 2025! Be safe, everyone, it’s a very crazy world we live in.



Eddie


All original content copyright, © 2011-2024. 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.

Saturday, December 21, 2024

TI 84 Plus CE: Consolidated Debts

TI 84 Plus CE: Consolidated Debts  


Disclaimer: This blog is for informational and academic purposes only. Financial decisions are your own.



Introduction


The program CONSOL consolidates a number of debts into a single loan, typically of a lower interest rate than the rate paid of the original debts. The loan can include additional cash and fees charged.



TI-84 Plus CE Program: CONSOL


Notes:


The percent sign is comprised of three symbols: a degree sign ( [ 2nd ], [ apps ] (angle), 1, °), the division slash, and a decimal point. The percent symbol will look something like this: ° / .


All fees are assumed to be financed. At the fees question, if you enter an amount less than 100, it will be treated as a percent of the desired cash out. If you enter an amount 100 or above, it will be treated as an amount. For no fees, enter 0.


Monthly payments at the end of the month are assumed.


The cash sign convention is used. If the interest difference is positive, you are saving interest costs. If the interest difference is negative, you have an additional interest cost.


The list of original debts are stored to list L₄.

The list of associated rates are stored to list L₅.

The list of associated number of payments renaming to list L₆.


The payment function, tvm_Pmt is from the Finance app ( [ apps ], 1. Finance…, 2: tvm_Pmt). Syntax: tvm_Pmt( number of payments, annual interest rate, present value, future value, payments per year, compound periods per year).


Code (520 bytes):


ClrHome

Disp “CONSOLIDATED ANALYSIS”

Input “LIST OF DEBTS? “, L₄

Input “LIST OF RATES (°/.)? “, L₅

Input “LIST OF PMTS REMAINING? “, L₆

If dim(L₄)≠dim(L₅) or dim(L₅)≠dim(L₆) or dim(L₄)≠dim(L₆)

Then

Disp “LISTS NOT EQUAL SIZE”

Stop

End

0 → J

For(I, 1, dim(L₄))

L₆(I) * tvm_Pmt(L₆(I), L₅(I), L₄(I), 0, 12, 12) + L₄(I) + J → J

End

sum(L₄) → D

Disp “CONSOLIDATED DEBT:”, D

Input “DESIRED AMOUNT? “, C

Disp “FEES AND COSTS”, “<100 (°/.), ≥100 (AMT)”

Prompt F

If F<100

Then

C*(1+F/100) → F

Else

C+F → F

End

Input “NEW RATE (°/.)? “, R

Input “NO. OF PMTS? “, N

tvm_Pmt(N,R,F,0,12,12) → p

N*P+F → K

Disp “CASH OUT: “, C-D

Disp “NEW PMT: “, P

Disp “INTEREST DIFF: “,”(>0 SAVINGS)”, K-J



Examples


Example 1: A Simple Consolidation


Consolidate two debts, take no cash out, no fees.


Original Debt

Interest Rate

Number of Payments Left

48000

8%

240

17500

19.99%

24





Desired Amount: 65500. No fees. New rate: 6%. Term: 240 months


Result:

Cash Out: 0

New Pmt: -469.2623433 (469.26)

Interest Diff: 5109.118945 (save 5109.12)


Example 2: Consolidate Three Debts: 3% fees or a flat 600 fee.


Original Debt

Interest Rate

Number of Payments Left

36500

12.99%

180

6800

8%

80

1800

20.99%

12


Desired Amount: 52000. New Rate: 7.25%. Term: 240 months


Result with 3% fees:

Cash Out: 6900

New Pmt: -423.3253775 (-423.33)

Interest Diff: 752.12157 (752.12)


Result with 600 flat fee:

Cash Out: 6900

New Pmt: -415.7377681 (415.74)

Interest Diff: 1613.147839 (1613.15)


Example 3: Not every scenario will have interest savings.


Original Debt

Interest Rate

Number of Payments Left

40000

13%

90

4000

20.99%

12

1800

9.95%

12


Desired Amount: 50000. New Rate: 7%. Term: 180 months. Fees: 3%


Result with 3% fees:

Cash Out: 4200

New Pmt: -462.8965595 (462.90)

Interest Diff: -8434.001105 (-8434.00)


Download the file here: https://drive.google.com/file/d/171aj-kTKH0-YZCyeMDHZMxqpGERaaAhd/view?usp=sharing



Happy Holidays! Take care and be well,


Eddie


All original content copyright, © 2011-2024. 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.

RPN with HP 15C & DM32: Solving Simple Systems

RPN with HP  15C & DM32: Solving Simple Systems Welcome to another edition of RPN with HP 15C & DM32. Many Approaches to a...