def quadratic_roots(a: float, b: float, c: float) -> Tuple[Union[float, complex], Union[float, complex]]: """Return both roots of ax^2 + bx + c = 0.""" if a == 0: raise ValueError("Coefficient a cannot be zero (not quadratic).") disc = b b - 4 a c if disc >= 0: sqrt_disc = math.sqrt(disc) return ((-b - sqrt_disc) / (2 a), (-b + sqrt_disc) / (2 a)) else: sqrt_disc = math.sqrt(-disc) return (complex(-b/(2 a), -sqrt_disc/(2 a)), complex(-b/(2 a), sqrt_disc/(2*a)))
: Converts standard Word documents (including complex formulas and tables) into clean LaTeX code. danlwd grindeq math utilities
Even a powerful toolkit like Danlwd Grindeq has its quirks: def quadratic_roots(a: float, b: float, c: float) ->