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.

Saturday, December 14, 2024

RPN with HP 15C & DM32: Swapping Items in the Stack

RPN with HP 15C & DM32: Swapping Items in the Stack



A New Series


Welcome to a new series: RPN with the HP 15C & DM32. The DM32 is the Swiss Micros updated calculator of the popular model HP 32SII. The intended schedule for this series is the second Saturday starting now until at least December 13, 2025.



Product Information:


Hewlett Packard HP 15C Collector’s Edition: https://www.thecalculatorstore.com/p/hp15c-collector-s-edition-2


Swiss Micros DM15L: https://www.swissmicros.com/product/dm15l


Hewlett Packard HP 32SII (original, late 1980s-1990s, video by Logan West): https://www.youtube.com/watch?v=g4eP5ckeo9g


Swiss Micros DM32: https://www.swissmicros.com/product/model-dm32


There here plenty of emulators for the HP 15C for the smartphone, both Android and Apple iPhone iOS.



Swapping the Stack’s Elements


Our first installment of the series deals with swapping elements of the stack. Like most RPN calculators, the HP 15C and DM32 have four stack levels.


T

Z

Y

X


The stack contains four values. On the HP 15C, the stack can also contain complex numbers and matrices.


On most RPN calculators, the stack is a Rolodex of four values. The can be scrolled up (R↑) and down (R↓). The contents of the x and y stack values can be swapped by the swap key (x<>y). On RPN calculators that show one line, like the HP 15C, the value that is shown is the X stack. Some RPN calculators, such as the DM32, show all four stack levels (X, Y, Z, and T).


The following keystrokes the values on two stack levels using the stack operations R↑, R↓, and x<>y. They are multiple algorithms to accomplish each task, I will present one for each.


For illustration purposes, an example stack always starts out as:

T: 40

Z: 30

Y: 20

X: 10


You don’t need to key in these numbers, this is for illustration purposes.

Swap X and Y: x<>y

Result:

T: 40

Z: 30

Y: 10

X: 20


Swap X and Z: x<>y, R↓, R↓, x<>y, R↓

Result:

T: 40

Z: 10

Y: 20

X: 30


Swap X and T: R↑, x<>y, R↓

Result:

T: 10

Z: 30

Y: 20

X: 40


Swap Y and Z: R↓, x<>y, R↑

Result:

T: 40

Z: 20

Y: 30

X: 10


Swap Y and T: R↓, x<>y, R↓, R↓, x<>y

Result:

T: 20

Z: 30

Y: 40

X: 10


Swap Z and T: R↓, R↓, x<>y, R↓, R↓

Result:

T: 30

Z: 40

Y: 20

X: 10


An excellent resource to use is Better Program on the HP-67/97, a PPC Publication, edited by William Kolb, John Kennedy, and Richard Nelson (1978). https://www.cuveesoft.ch/rpn67/img/HP67%20Better%20Programming%20PPC.pdf



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 7, 2024

Casio fx-CG50 and TI-84 Plus CE: Multiple Linear Regression

Casio fx-CG50 and TI-84 Plus CE: Multiple Linear Regression


We have arrived at the last month of 2024. What a crazy year. I hope for smoother and peaceful times ahead.



Introduction


The program MLREG fits bi-variate data to the linear regression equation:


y = b0 + b1 * t + b2 * x


where t and x are the independent variables, and y is the dependent variable. The program uses a numerical method known as normal equations, to solve the system:


n * b0 + Σ(t) * b1 + Σ(x) * b2 = Σ(y)

Σ(t) * b0 + Σ(t^2) * b1 + Σ(t*x) * b2 = Σ(t*y)

Σ(x) * b0 + Σ(t*x) * b1 + Σ(x^2) * b2 = Σ(x*y)


or in matrix form:


[ [ n ,Σ(t), Σ(x) ] [ Σ(t), Σ(t^2), Σ(t*x) ] [ Σ(x), Σ(t*x), Σ(x^2) ] ] * [ [ b0 ] [ b1 ] [ b2 ] ]

= [ [ Σ(y) ] [ Σ(t*y) ] [ Σ(x*y) ] ]


where:

n is the number of data points,

Σ(t) is the sum of all t data,

Σ(x) is the sum of all x data,

Σ(y) is the sum of all y data,

x * t, t * y, x * y, t^2, x^2 are all represent of the variable element-by-element multiplication of each set


The calculator programs assign the following variables:

n * b0 + Σ(t) * b1 + Σ(x) * b2 = Σ(y)

Σ(t) * b0 + Σ(t^2) * b1 + Σ(t*x) * b2 = Σ(t*y)

Σ(x) * b0 + Σ(t*x) * b1 + Σ(x^2) * b2 = Σ(x*y)


A = n

B = Σ(t)

C = Σ(x)

D = Σ(t^2)

E = Σ(t*x)

F = Σ(x^2)

X = Σ(y)

Y = Σ(t*y)

Z = Σ(x*y)




Casio fx-CG 50 Program: MLREG


This is programmed in Casio Basic.


“Y=B0+B1×T+B2×X”

“T LIST”? → List 4

“X LIST”? → List 5

“Z LIST”? → List 6

If Dim List 4 ≠ Dim List 5 Or Dim List 5 ≠ Dim List 6 Or Dim List 4 ≠ Dim List 6

Then

“LISTS NOT SAME LENGTH” ◢

Stop

IfEnd

Dim List 4 → A

Sum List 4 → B

Sum List 5 → C

Sum (List 4²) → D

Sum (List 4 × List 5) → E

Sum (List 5²) → F

Sum List 6 → X

Sum (List 6 × List 4) → Y

Sum (List 6 × List 5) → Z

“B0,B1,B2=” ◢

[ [A, B, C ][B, D, E][C, E, F] ] ⁻¹ × [ [ X ][ Y ][ Z ] ] → Mat Z



TI-84 Plus CE Program: MLREG


ClrHome

Disp “Y=B0+B1*T+B2*X”

Input “T LIST: “, L₄

Input “X LIST: “, L₅

Input “Y LIST: “, L₆

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

Then

Disp “LISTS NOT EQUAL SIZE”

Stop

End

dim(L₄) → A

sum(L₄) → B

sum(L₅) → C

sum(L₄ ²) → D

sum(L₄ * L₅) → E

sum(L₅ ²) → F

sum(L₆) → X

sum(L₆ * L₄) → Y

sum(L₆ * L₅) → Z

[ [ A, B, C ] [ B, D, E ] [ C, E, F ] ] ⁻¹ * [ [ X ] [ Y ] [ Z ] ] → [ J ]

Disp “B0,B1,B2= “, [ J ]


Note: [ J ] is matrix J is called form the Matrix menu.



An Online Multiple Linear Regression Calculator


A multiple linear regression calculator which determine coefficients, quadrants, and other statistics can be found on the stats.blue web page: https://stats.blue/Stats_Suite/multiple_linear_regression_calculator.html


Examples


Example 1


t

x

y

1.12

22.3

100

1.16

22.1

104

1.19

21.8

107

1.23

21.4

110

1.28

21.1

114


Result:

B0 = -48.8333333

B1 = 99.99999999 (TI-84 Plus CE rounds this to 100)

B2 = 1.666666666


Equation:

y = -48.8333333 + 99.99999999 * t + 1.666666666 * x



Example 2


t

x

y

10.2

1.95

1000

10.5

3.00

1002

10.8

4.00

1005

11.1

4.95

1007

11.6

5.80

1009

11.8

6.75

1012

12.1

7.80

1015


Result:

B0 = 1008.157502

B1 = -1.429759754

B2 = 3.052897088


y = 1008.157502 – 1.429759754 * t + 3.052897088 * x


Until next time, when a new series will be introduced. Stay tuned,



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, November 30, 2024

TI-30Xa and HP 12C: Linear Interpolation

TI-30Xa and HP 12C: Linear Interpolation



Introduction


Linear interpolation allows us to estimate a point (x,y) given a linear relationship between points (x1,y1) and (x2,y2).


Given two points (x0, y0) and (x1, y1), and a point, x, we can easily estimate the y coordinate:


y = y0 + (x – x0) * (y1 – y0) / (x1 – x0)


Note that the slope of the line is:

m = (y1 – y0) / (x1 – x0)


This works the best when x is relatively real close to x0 and x1.


Fun fact, the y-intercept, where x = 0 can be calculated as:

b = y0 – x0 * m




TI-30Xa Algorithm: Linear Interpolation


This algorithm will require to enter information only once.


Store the following points:

x0 [ STO ] 1

y0 [ STO ] 2


Predict y:

[ ( ] x [ - ] [ RCL ] 1 [ ) ] [ × ] [ ( ] y1 [ - ] [ RCL ] 2 [ ) ] [ ÷ ] [ ( ] x1 [ - ] [ RCL ] 1 [ ) ] [ + ] y0 [ = ]




HP 12C Algorithm: Linear Interpolation


It turns out that we can use the linear regression functions for linear interpolation. Entering two points for linear regression will create a perfect line (with the correlation of 1 or -1). The algorithm presented is for the HP 12C, and a algorithm for other calculators can easily be made.


Keystrokes:


Enter (x0, y0) and (x1, y1):

[ f ] [ Clx ] (CLEAR FIN)

y0 [ ENTER ] x0 [ Σ+ ]

y1 [ ENTER ] x1 [ Σ+ ]


To calculate y:

x [ g ] [ 2 ] (y-hat, r)



Examples


Examples

X0

Y0

X1

Y1

X (Input)

Y (Output)

1

10

4.95

12

5.06

11

5.0050

2

21

48,057

23

52,165

22

50,111

3

1000

97.7

2000

94.2

1500

95.95



Source


“Linear interpolation” Wikipedia. Was Edited August 27, 2024. Retrieved September 4, 2024. https://en.wikipedia.org/wiki/Linear_interpolation


Until next time, as we head into the final month of 2024,



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, November 23, 2024

Fun with the HP 30b

Fun with the HP 30b



Introduction





The following programs are for the HP 30b Business Professional. Did you know that the 30b has a programming mode? The program mode has room for 10 programs with a total of 290 steps, where each key press is counted. Thankfully, shifts and hold-shifts are merged steps.


I couldn’t get the MSG or R/S commands to work properly. Therefore I use an approach that I often use for the Voyager calculators (HP 11C, 12C, 15C): store everything first and then run the program.


Disp5 is like the PSE (pause) command, it stops the execution for a second. Disp can be set to 1-9. Disp1 lasts for 1/5 second.


All programs are done in the Algebraic instead of the RPN I usually do on HP calculators.


All the results in the examples, except the last one, are rounded to four decimal places.



Program 0: f(x,y) = (x * y) / (x + y)


f(x, y) = (x * y) / (x + y)


Store x in memory 1 and y in memory 2.


Prog 0 =

RCL 1

×

RCL 2

÷

( ↓

RCL 1

+

RCL 2

) Swap

=

Stop


Examples:

x = 1.5, y = 16; Result: 1.3714

x = 3.6, y = 32; Result: 3.2360

x = 8.7, y = 10; Result: 4.6524



Program 1: PITI – Principal, Interest, Taxes, and Insurance


This program calculates the monthly payment of PI (principal and interest) and PITI (principal, interest, taxes, and insurance). The program assumes that payments per year setting (P/YR) is set to 12.


Store to Memory:

M1: Annual insurance rate.

M2: Annual property tax rate.

N: number of payments

I/YR: interest rate of the loan

PV: amount of the loan


It assumed that there is no balloon payment (FV = 0), although this program can be modified to include balloon payments by removing the first two steps (0 FV).


Prog 1 =

0

FV

PMT

Disp5

Disp5

-

( R↓

RCL 1

+

RCL 2

) Swap

/

1

2

0

0

*

RCL PV

=

Stop


Examples:


N = 360

I/YR = 8.9%

PV = 289000

Insurance Rate = 1% (1 STO 1)

Property Tax Rate = 1.3% (1.3 STO 2)


Result:

PMT: -2304.60

PITI: -2858.51



N = 360

I/YR = 8.9%

PV = 289000

Insurance Rate = 1% (1 STO 1)

Property Tax Rate = 1.3% (1.3 STO 2)


Result:

PMT: -2304.60

PITI: -2858.51



Program 2: Quadratic Equation – Po-Shen Lo Method

This program solves the monic quadratic polynomial:


x^2 + B * x + C = 0


where the solutions:

U^2 = B^2 / 4 – C

x1, x2 = - B / 2 ± √(U^2)


Store to Memory:

M1: B

M2: C


Prog 2 =

RCL 1

X^2

/

4

-

RCL 2

=

STO 0

-

RCL 1

/

2

=

STO 3

Disp5

Disp5

-

2

*

RCL 0

=

STO 4

Stop


M3: root 1 ( -B / 2 + √(U^2) )

M4: root 1 ( -B / 2 + √(U^2) )


This program finds real roots only. If there are no real roots, then the program displays an error.


Examples:


x^2 – 2 * x – 24 = 0

B = -2 STO 1

C = -24 STO 2

Roots: 6, -4


x^2 – 10 * x + 21 = 0

B = -10 STO 1

C = 21 STO 2

Roots: 3, 7



Program 3: Lease with Advanced Payments (HP 12C – see source)


This program calculates the regular monthly payment of a lease when the borrower pays a set number of payments in advance. Payments per year (P/YR) is assumed to be set at 12 while the calculator is set to End of Period payments.


Store in Memory:

number of payments [ N ]

annual lease rate [ I/YR ]

residual value [ FV ]

number of payments to be made in advance [ STO ] 0

loan amount [ STO ] 1 (not PV)


Prog 3 =

0

PMT

0

PV

PV

+

RCL 1

=

STO 2

0

FV

RCL N

-

RCL 0

=

N

1

+/-

PMT

( R↓

PV

+

RCL 0

) Swap

1/X

*

RCL 2

=

Stop


Examples:


Total Payments: 48 [ N ]

Rate: 13 [ I/YR ]

Residual Value: 7,000 [ FV ]

Payments in Advance: 1 [ STO ] 0

Loan Amount: 25,000 [ STO ] 1


Result: -536.06



Total Payments: 60 [ N ]

Rate: 8.8 [ I/YR ]

Residual Value: 12,000 [ FV ]

Payments in Advance: 3 [ STO ] 0

Loan Amount: 118,000 [ STO ] 1


Result: -2,229.71



For those of you in the United States, Happy Thanksgiving!


Source


Hewlett Packard. HP 12C Financial Calculator: User’s Guide. Edition 5. 2008. San Diego, CA. pp. 124-126


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.

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 ...