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

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 Varibles:

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

+IF(S(X2):IF(D

Input Variables:

A: coefficient of X^2

B: coefficient of X

C: constant

Output Variables:

D: Discriminant

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