functionrootsPolyOrder3

Find the roots of a 3 order polynome of kind ax3 + bx2 + cx + d = 0

Extends from Modelica.Icons.Function (Icon for functions).

Information

rootsPolyOrder3

This function computes the vector of roots, roots=(x1, x2, x3}, of third order polynom P(x):

The process to get the roots derives from CARDAN's method available at the following link.
To sum up:

  • The following change of variable is performed to derive to:

  • if the determinant Δ of the 3rd order polynom is strictly positif (Δ > 0), the roots derive:
  • if Δ = 0, the roots derive:
  • if Δ > 0, the only real root derives:
  • If 'a' is bellow 1e-10, the polynom is assumed to be 2nd order

    The discriminant of the second order polynom derives:

  • If Δ < 0, there are no real root and an error message is raised.
  • If Δ = 0, there is one double solution:
    • If Δ > 0, the two real roots derives.
    If 'a' and 'b' are bellow 1e-10, the polynom is assumed to be 1st order

    The first root derives:

    In case where a roots has no assigned value, its default value is 0.

    Inputs

    TypeNameDefaultDescription
    RealaPolynom coefficients
    RealbPolynom coefficients
    RealcPolynom coefficients
    RealdPolynom coefficients

    Outputs

    TypeNameDefaultDescription
    Real[3]roots