2nd degree equations


Solve a 2nd degree equation using the quadratic formula

Preview of this algorithm

Icon Variable
Ask for a with default 1
Icon Variable
Ask for b with default 7
Icon Variable
Ask for c with default 12
Icon Structure
If a != 0
Icon Variable
Set Δ to b ^ 2 - 4ac
Icon Variable
Set α to (-b) / (2a)
Icon Variable
Set β to (-Δ) / (4a)
Icon Output
Print text f(x) = "ax ^ 2 + bx + c"
Icon Output
Print text f(x) = "a(x - α) ^ 2 + β"
Icon Output
Print variable Δ
Icon Structure
If Δ = 0
Icon Variable
Set x_0 to α
Icon Output
Print variable x_0
Icon Output
Print text f(x) = "a(x - x_0) ^ 2"
Icon Structure
Else
Icon Variable
Set x_1 to (-b - √(Δ)) / (2a)
Icon Variable
Set x_2 to (-b + √(Δ)) / (2a)
Icon Output
Print variable x_1
Icon Output
Print variable x_2
Icon Output
Print text f(x) = "a(x - x_1)(x - x_2)"
Icon Structure
End
Icon Structure
End