Tuesday, March 26, 2019

HP 17BII and HP 27S: Quadratic Formula

HP 17BII and HP 27S:  Quadratic Formula


The following solver equations solve the quadratic equation

A*x^2 + B*x + C = 0

by the famous Quadratic Formula

x = (-B ± √(B^2 - 4*A*C) ) / (2*A)

Define D as the discriminant:  D = B^2 - 4*A*C

If A, B, and C are real numbers and:

D<0, the roots are complex conjugates

D≥0, the roots are real roots

Quadratic Equation:  Real Roots Only

QUAD:X=INV(2*A)*(-B+SQRT(B^2-4*A*C)*SGN(R#))

Input Variables:
A:  coefficient of X^2
B:  coefficient of X
C:  constant
R#:  -1 or 1

Output Variables: 
X:  root

Example:  2X^2 + 3X - 5 = 0

Input:
A: 2
B: 3
C: -5
R#: 1 (or any positive number)

Output:
X = 1

Input:
R#: -1

Output:
X = -2.5

Quadratic Equation:  Real or Complex Roots
(Let (L) and Get (G) functions required)

QUAD:0*(A+B+C+L(D:B^2-4*A*C)+L(E:2*A))
+IF(S(X1):IF(D<0:-B÷G(E):(-B+SQRT(D))÷G(E))-X1:0)
+IF(S(X2):IF(D<0:SQRT(ABS(D))÷G(E):(-B-SQRT(D))÷G(E))-X2:0)

 Input Variables:
A:  coefficient of X^2
B:  coefficient of X
C:  constant

Output Variables:
D:  Discriminant 
If D<0:  X1:  real part, X2:  imaginary part
If D≥0:  X1:  real root 1, X2:  real root 2

Example 1:  -3*X^2 + 8*X - 1= 0

Input:
A: -3
B: 8
C: -1

Output:
D = 52
X1 = 0.1315
X2 = 2.5352

Roots:  x = 0.1315, x = 2.5352

Example 2:  3*X^2 + 5*X + 3 = 0

Input: 
A: 3
B: 5
C: 3

Output:
D = -11
X1 = -0.8333
X2 = 0.5528

Roots:  x = -0.8333 ± 0.5528i

Eddie

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

Spotlight: TI-55 from 1977

Spotlight: TI-55 from 1977 Welcome to a special Monday Edition of Eddie’s Math and Calculator Blog. Today, we have the origi...