You are on page 1of 1

# Example 1 - Solution of a quadratic equation.

a = 1 # constant of the equation: ax^2+bx+c=0 b = -12 # constant of the equation: ax^2+bx+c=0 c = 35 # constant of the equation: ax^2+bx+c=0 disc = b ^ 2 - 4 * a * c # discriminant of the equation: ax^2+bx+c=0 x1 = If (disc >= 0) Then (-b + sqrt(disc)) / (2 * a) Else (0) # First root for disc>=1 x2 = If (disc >= 0) Then (-b - sqrt(disc)) / (2 * a) Else (0) # Second root for disc>=1 real1 = If (disc < 0) Then (-b / (2 * a)) Else 0 # real part of the first root for disc<0 imag1 = If (disc < 0) Then (sqrt(-disc) / (2 * a)) Else 0 # imaginary part of the first root for disc<0

You might also like