Function.quadratic_solve()

6. API Reference: `Function.quadratic_solve()` Method

For the special case of degree-2 polynomials (quadratics), the Function class provides a direct, analytical solver method using the quadratic formula. This is much faster and more precise than the genetic algorithm for this specific case.

from polysolve import Function
# f(x) = x² - x - 6
f_quad = Function(2)
f_quad.set_coeffs([1, -1, -6])
# Call the analytical solver method
exact_roots = f_quad.quadratic_solve()
print(exact_roots) # Output: [-2.0, 3.0]

The method returns a sorted list containing two floats. If the quadratic has no real roots (i.e., the discriminant is negative), it will return None.