matician - v2.0.0
    Preparing search index...

    Function solveQuadratic

    • Solves a quadratic equation of the form ax² + bx + c = 0.

      Returns roots as an array of objects: { real: number, imag: number }. Ensures no -0 values in results.

      Parameters

      • a: number

        Coefficient of x²

      • b: number

        Coefficient of x

      • c: number

        Constant term

      Returns { imag: number; real: number }[]

      An array of two roots (real or complex)

      solveQuadratic(1, 0, -4); // [{ real: 2, imag: 0 }, { real: -2, imag: 0 }]
      solveQuadratic(1, 0, 4); // [{ real: 0, imag: 2 }, { real: 0, imag: -2 }]