Showing posts with label quadratic equation. Show all posts
Showing posts with label quadratic equation. Show all posts

Saturday, August 1, 2026

DM42 and HP 42S: Quadratic Equation, Characteristic Polynomial, and Eigenvalues

DM42 and HP 42S: Quadratic Equation, Characteristic Polynomial, and Eigenvalues




The programs are listed for the Swiss Micros DM42 and Hewlett Packard 42S.



All examples are on rounded to four decimal places and complex mode turned on (CPXRES).



Monic Quadratic Equation: quad2.raw



The program QUAD2 solves the equation for w:

w² + Y * w + X = 0

Y: contents of stack Y

X: contents of stack X



Code:

00 { 35-Byte Prgm }

01▸LBL "QUAD2"

02 X<>Y

03 ENTER

04 2

05 ÷

06 +/-

07 ENTER

08 X↑2

09 X<>Y

10 R↓

11 X<>Y

12 -

13 SQRT

14 R↑

15 X<>Y

16 ENTER

17 ENTER

18 R↑

19 ENTER

20 R↓

21 X<>Y

22 +

23 R↓

24 -

25 R↑

26 RTN

27 .END.



Example 1: w² + 7 * w + 5 = 0

Stack: Y: 7, X: 5

Results: -6.1926, -0.8074



Example 2: w² – 4 = 0

Stack: Y: 0, X: -4

Results: -2.0000, 2.0000



Characteristic Polynomial: char2.raw



The program CHAR2 find the coefficients of 2 x 2 matrix:

[ [ A, B ] [ C , D ] ]

Result: λ² – T1 * λ + T2 = 0 where

T1 = A + D

T2 = det([[ A, B ] [ C, D ]]) = A * D – C * B



The program provides prompts and results in messages.



Code:

00 { 81-Byte Prgm }

01▸LBL "CHAR2"

02 "[[A,B][C,D]]"

03 AVIEW

04 PSE

05 PSE

06 "L↑2-T1×L+T2=0"

07 AVIEW

08 PSE

09 PSE

10 INPUT "A"

11 ENTER

12 ENTER

13 INPUT "D"

14 ENTER

15 R↓

16 +

17 "T1= "

18 ARCL ST X

19 AVIEW

20 STOP

21 R↓

22 ×

23 INPUT "C"

24 INPUT "B"

25 ×

26 -

27 "T2= "

28 ARCL ST X

29 AVIEW

30 RTN

31 .END.



Example 1: [ [ -6, 4 ] [ 2, 3 ] ]

Results: T1: 3, T2: -26



Example 2: [ [ 5, 8 ] [ -1, 2 ] ]

Results: T1: 7, T2: 18



Eigenvalues of 2 x 2 Matrices: egn2.raw



The program EGNV2 calculates the eigenvalues of a 2 x 2 matrix:

[ [ A, B ] [ C , D ] ]



The program provides prompts and results in messages. The command CPXRES sets the calculator to accept complex number results.



Code:

00 { 106-Byte Prgm }

01▸LBL "EGNV2"

02 CPXRES

03 "[[A,B][C,D]]"

04 AVIEW

05 PSE

06 PSE

07 INPUT "A"

08 INPUT "B"

09 INPUT "C"

10 INPUT "D"

11 RCL "A"

12 RCL "D"

13 +

14 +/-

15 RCL "A"

16 RCL "D"

17 ×

18 RCL "B"

19 RCL "C"

20 ×

21 -

22 X<>Y

23 ENTER

24 2

25 ÷

26 +/-

27 ENTER

28 X↑2

29 X<>Y

30 R↓

31 X<>Y

32 -

33 SQRT

34 R↑

35 X<>Y

36 ENTER

37 ENTER

38 R↑

39 ENTER

40 R↓

41 X<>Y

42 +

43 "E1="

44 ARCL ST X

45 AVIEW

46 PSE

47 PSE

48 R↓

49 -

50 "E2="

51 ARCL ST X

52 AVIEW

53 PSE

54 PSE

55 R↑

56 RTN

57 .END.



Example 1: [ [ -6, 4 ] [ 2, 3 ] ]

Results: 3.8151, - 6.8151



Example 2: [ [ 5, 8 ] [ -1, 2 ] ]

Results: 3.5 ± 2.37792 i


You can download the three programs here: https://drive.google.com/file/d/1SKcVIhKYHnnuhrvBJxfOmwsV8sRTSj0X/view?usp=sharing





Eddie


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

fx-3650P and TI-68: Quadratic Equation and Arc Length between Roots of a Quadratic Curve

fx-3650P and TI-68: Quadratic Equation and Arc Length between Roots of a Quadratic Curve


Two approaches using two well-liked, classic calculators. The fx-3650P uses Basic like language while the TI-68 handles formulas.



Quadratic Equation


Solve for A x^2 + B x + C = 0, with the discriminant D = B^2 – 4 * A * C.


We know the solutions: X = (-B ± √(B² – 4 * A * C)) / (2 * A)


fx-3650P Program

? → A : ? → B : ? → C :

B² – 4 A C → D ◢

-B ÷ ( 2 A ) → M :

√ ( √ ( D² ) ) ÷ ( 2 A ) → Y :

D ≥ 0 ⇒ Goto 1 : M ◢ Y ◢ Goto 2 :

Lbl 1 : M + Y → X ◢ M – Y → Y ◢ Lbl 2


D: discriminant

If D<0; roots are in the form of M ± Yi

Else, the roots are real and are stored in X, Y


TI-68 Formula


X = 0 × A + (-B + √(B² – 4 × C × A) × J) ÷ (2 × A)


The 0 × A is added to force A to be prompted for first.

J = -1 for one root, J = 1 for the other

TI-68 takes care of both real and complex roots, no worries.

The coefficients can be complex!


Examples

A

B

C

D

Roots

2

-3

-9

81

3, -1.5

1

0

25

-100

5i, -5i

-48

64

28

9472

-0.347127088, 1.680464022



Arc Length of a Quadratic Equation between its Real Roots


Give roots X, Y: (t – X) * (t – Y) = t^2 – (X + Y )* t + X * Y

f(t) = t^2 – (X + Y) * t + X * Y

f’(t) = 2 * t – (X + Y)

arc = ∫( √(1 + f’(t)^2) dt


TI-68 will set up for the outside integral function, while the fx-3650P can use the integral function inside of the program.


We are going to assume that X < Y.


fx-3650P Program

? → A : ? → B : ∫ ( √ (1 + (2 X – A – B) ² ), A, B)


This is the direct approach.


TI-68 Formula

ARC = √(1 + (2 × X – A – B)²)


for X use the integral function (dx)

[ 3rd ] [ Σ+ ] (dx) [ = ]

Enter low, high, and the number of intervals.

The more intervals, generally, the more accurate the integral is.


Examples

I compared results against the fx-991CW.


A

B

TI-68, intv = 16

fx-3650P

fx-991 CW

2

9

26.070832160

26.070800000

26.070797720

0

5

13.903768900

13.904000000

13.903767950

-2

2

9.293567375

9.293568000

9.293567525



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.


The author does not use AI engines and never will.


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.

Saturday, June 29, 2024

TI 30Xa Algorithms: Solving Monic Quadratic Polynomials Quickly

 TI 30Xa Algorithms: Solving Monic Quadratic Polynomials Quickly


We all know about the tried and true Quadratic Formula to solve quadratic equations. However, it is not the only way to tackle such problems.



Today’s blog is covers a way to quickly get the roots of the quadratic equation:


x^2 + p * x + q = 0


I am focusing on monic quadratic polynomials today. A polynomial is a monic polynomial if the leading coefficient is 1. In this instance, the coefficient of the x^2 term is 1. I’m also going to work with quadratic equations that have real roots.



Deviation


Please see the source article as the derivation and method is explained by the author Po-Shen Loh (https://www.poshenloh.com/quadraticdetail/). This method has also been developed by Viete and other classic mathematicians. Here I attempt to explain a derivation of this method.


Let r1 and r2 be the two roots of the polynomial and x^2 + p * x + q factors to:

x^2 + p * x + q = (x – r1) * (x – r2)


Expanding (x – r1) * (x – r2):

(x – r1) * (x – r2) = x^2 + (-r1 -r2) * x + r1 * r2


Then:

p = - r1 – r2 ⇒ r1 + r2 = -p

q = r1 * r2


Let one of the roots be defined as: [see Source]

r1 = -p/2 + u

Then:

r1 + r2 = -p

-p/2 + u + r2 = -p

r2 = -p/2 + u


And:

r1 * r2 = q

(-p/2 + u) * (-p/2 - u) = q

p^2/4 – u^2 = q

- u^2 = q – p^2/4

u^2 = p^2/4 – q

u = ±√(p^2/4 – q)


And the roots are:

r1 = -p/2 + √(p^2/4 – q)

r2 = -p/2 - √(p^2/4 – q)


x = -p/2 ± u


Note:

r1 = -p/2 + u

r1 – 2 * u = -p/2 + u – 2 * u

r1 – 2 * u = -p/2 – u

r1 – 2* u = r2



We can verify the above result with the quadratic equation:


x = (-p ± √( p^2 – 4 * q)) / 2

x = -p/2 ± √( p^2 – 4 * q) / 2

x = -p/2 ± √(( p^2 – 4 * q) / 4)

x = -p/2 ± √(( p^2/4 – q)

x = -p/2 ± u




TI-30Xa Algorithm: Quadratic Equation


Assumption: The roots are real (not complex).


Keystrokes:

p [ STO ] 1

q [ STO ] 2

[ ( ] [ RCL ] 1 [ x^2 ] [ ÷ ] 4 [ - ] [ RCL ] 2 [ ) ] [ √ ] (u)

[ - ] [ RCL ] 1 [ ÷ ] 2 [ = ] (r1, root 1)

[ ± ] [ - ] [ RCL ] 1 [ = ] (r2, root 2)


Memory registers used: M1 = p, M2 = q


Examples


Example 1: x^2 – 3*x – 4 = 0


p = -3, r = -4


3 [ ± ] [ STO ] 1

4 [ ± ] [ STO ] 2

[ ( ] [ RCL ] 1 [ x^2 ] [ ÷ ] 4 [ - ] [ RCL ] 2 [ ) ] [ √ ] (u = 2.5)

[ - ] [ RCL ] 1 [ ÷ ] 2 [ = ] (root 1, x = 4)

[ ± ] [ - ] [ RCL ] 1 [ = ] (root 2, x = -1)


x = 4, -1


Example 2: x^2 – 24*x + 135 = 0

p = -24, r = 135


24 [ ± ] [ STO ] 1

135 [ STO ] 2

[ ( ] [ RCL ] 1 [ x^2 ] [ ÷ ] 4 [ - ] [ RCL ] 2 [ ) ] [ √ ] (u = 3)

[ - ] [ RCL ] 1 [ ÷ ] 2 [ = ] (root 1, x = 15)

[ ± ] [ - ] [ RCL ] 1 [ = ] (root 2, x = 9)


x = 15, 9


Example 3: x^2 + 10*x + 24 = 0

p = 10, r = 24

10 [ STO ] 1

24 [ STO ] 2

[ ( ] [ RCL ] 1 [ x^2 ] [ ÷ ] 4 [ - ] [ RCL ] 2 [ ) ] [ √ ] (u = 1)

[ - ] [ RCL ] 1 [ ÷ ] 2 [ = ] (root 1, x = -4)

[ ± ] [ - ] [ RCL ] 1 [ = ] (root 2, x = -6)


x = -4, -6



Source


Loh, Po-Shen. “Quadratic Method: Detailed Explanation” Updated August 6, 2021. Retrieved May 19, 2024. https://www.poshenloh.com/quadraticdetail/


Until next time, have a great day. For the Americans, have a safe and sane Fourth of July. See you July 6!


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.

Python: Drawing a Ring of Circles

Python: Drawing a Ring of Circles The goal: Draw a number of circles that revolve around the origin (0,0). The center of each circle i...