Quadratic Formula

Description

By Eddie Shore, November 2011 (Eddie's Math and Calculator Blog)

This program find the roots the quadratic equation:

ax2 + bx + c = 0

Instructions:
1. Store a in R0, b in R1, and c in R2.
2. Press f A.
3. The discriminant is displayed (R0).
4. Press R/S displays R4.
5. Press R/S displays R5.

If R0 ≥ 0, R4 and R5 are the real roots of the quadratic equation.

If R0 < 0, R4 is the real part of the complex root, and R5 is ±imaginary part of the complex root.

Example 1:

x2 + 4x + 6 → R1 = 1, R2 = 4, R3 = 6
Result:
R0 = -8, R4 = -2, R5 ≈ 1.4142
The roots are -2 ± √2 i

Example 2:

x2 - 5x + 3 → R1 = 1, R2 = -5, R3 = 3
Result:
R0 = 13, R5 ≈ 0.6972, R4 ≈ 4.3028
The roots are approximately 0.6972 and 4.3028.

Program Resources

Labels

Name Description
 A Calculate Roots of the Quadratic Equation
 0 Complex Roots Subroutine
 1 -b/2a Subroutine

Storage Registers

Name Description
 0 Discriminant; b^2 - 4 a c
 1 a
 2 b
 3
 4 Root 1/Real Part
 5 Root 2/Imaginary Part

Program

Line Display Key Sequence Line Display Key Sequence
000 024 2 2
001 42,21,11 f LBL A 025 20 ×
002 45 2 RCL 2 026 30
003 43 11 g 027 44 5 STO 5
004 4 4 028 43 32 g RTN
005 45,20, 1 RCL × 1 029 42,21, 0 f LBL 0
006 45,20, 3 RCL × 3 030 32 1 GSB 1
007 30 031 44 4 STO 4
008 44 0 STO 0 032 31 R/S
009 31 R/S 033 45 0 RCL 0
010 43,30, 2 g TEST x<0 034 43 16 g ABS
011 22 0 GTO 0 035 11 √x̅
012 4 4 036 2 2
013 10 ÷ 037 10 ÷
014 45 1 RCL 1 038 45,10, 1 RCL ÷ 1
015 43 11 g 039 44 5 STO 5
016 10 ÷ 040 43 32 g RTN
017 11 √x̅ 041 42,21, 1 f LBL 1
018 32 1 GSB 1 042 45 2 RCL 2
019 34 x↔y 043 16 CHS
020 40 + 044 2 2
021 44 4 STO 4 045 10 ÷
022 31 R/S 046 45,10, 1 RCL ÷ 1
023 43 36 g LSTΧ 047 43 32 g RTN