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.
function rootsPolyOrder3
extends Modelica.Icons.Function;
input Real a "Polynom coefficients";
input Real b "Polynom coefficients";
input Real c "Polynom coefficients";
input Real d "Polynom coefficients";
output Real roots[3];
end rootsPolyOrder3;
Generated at 2024-11-22T19:25:38Z
by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos