03-26-2019, 04:05 PM

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

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)

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

Link: https://edspi31415.blogspot.com/2019/03/...rmula.html

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

Code:

`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)

Code:

`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

Link: https://edspi31415.blogspot.com/2019/03/...rmula.html