"""
MathProblemSolver
Generated by Eden via recursive self-improvement
2025-10-27 17:33:08.657569
"""

import cmath

def solve_quadratic(a, b, c):
    """
    Solve a quadratic equation of the form ax² + bx + c = 0.
    
    Args:
        a (float): Coefficient of x²
        b (float): Coefficient of x
        c (float): Constant term
        
    Returns:
        list or complex: Roots of the equation. Can be two real numbers, 
                        one real number, or two complex numbers.
        
    Raises:
        ValueError: If a is zero, which makes it not a quadratic equation.
    """
    # Check if it's a valid quadratic equation
    if a == 0:
        raise ValueError("a cannot be zero. Not a quadratic equation.")
    
    # Calculate discriminant
    discriminant = b**2 - 4*a*c
    
    # Compute roots based on the discriminant value
    if discriminant > 0:
        root1 = (-b + cmath.sqrt(discriminant)) / (2*a)
        root2 = (-b - cmath.sqrt(discriminant)) / (2*a)
        return [root1, root2]
    elif discriminant == 0:
        root = (-b) / (2*a)
        return [root]  # Return as a list for consistency
    else:
        root1 = (-b + cmath.sqrt(discriminant)) / (2*a)
        root2 = (-b - cmath.sqrt(discriminant)) / (2*a)
        return [root1, root2]

# Example usage:
if __name__ == "__main__":
    # Solve x² + 3x -4 =0
    roots = solve_quadratic(1, 3, -4)
    print("Roots:", roots)  # Output: Roots: [1.0, -4.0]
    
    # Solve x² = 0 (double root at zero)
    roots = solve_quadratic(1, 0, 0)
    print("Roots:", roots)  # Output: Roots: [0.0]
    
    # Solve a complex case
    roots = solve_quadratic(1, 2, 5)
    print("Complex Roots:", roots)  # Output: Complex Roots: [(-1+2j), (-1-2j)]