![]() |
| the quadratic roots |
if b^2 - 4 * a * c is greater than zero, then the roots are complex numbers.
complex number i, python uses j instead for -1 under root.
in Python,
import sqrt
from numpy.lib.scimath import sqrt
then,
root1 = -b + sqrt(b**2 - 4*a*c))/ (2*a)
root2 = -b - sqrt(b**2 - 4*a*c))/ (2*a)
where f(x) = ax^2 + bx + c

No comments:
Post a Comment