Function quadratic

  • Solve for x in a second-order polynomial such as ax^2 + bx + c = 0 using the quadratic formula.

    Parameters

    • a: number

      The quadratic coefficient.

    • b: number

      The linear coefficient.

    • c: number

      The constant coefficient.

    Returns number[]

    Returns the roots.

    Since

    0.5.0

    Example

    quadratic(1, 2, 1)
    // => [-1]
    quadratic(2, 4, -6)
    // => [1, -3]
    quadratic(1, 1, 1)
    // => [NaN, NaN]