Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's Texas Code Snippets.
A program to calculate and interpret the results of a quadratic equation.
A quadratic equation can be written in the form below.
a.x2 + b.x + c = 0
First the discrimant must be calculated:
D = b2 - 4.a.c
If the discriminant is below zero, the equation has no solution.
If the discriminant is zero, the equation has a single solution. The solution will be equal to the formula below:
x = (-b) / (2.a)
If the discriminant is above zero, the equation has two solutions. The solutions can be calcultaed by the formulas below:
x1 = (-b + √(D) ) / (2.a)
x2 = (-b - √(D) ) / (2.a)
The code in the Texas TI-84 might look like this:
: ClrHome
:
: Prompt A
: Prompt B
: Prompt C
:
: (B*B)-(4*A*C) -> D
:
: Disp "Discriminant:"
: Disp D
:
: If D<0
: Then
: Disp "No solution."
: End
:
: If D=0
: Then
: Disp "1 solution:"
: -B / (2*A) -> E
: Disp E
: End
:
: If D>0
: Then
: Disp "2 solutions:"
: (-B+√(D)) / (2*A) -> E
: (-B-√(D)) / (2*A) -> F
: Disp E
: Disp F
: End
: