.Modelica_LinearSystems2.Math.Polynomial.roots

Information

Syntax

result = Polynomial.roots(p, printRoots);

Description

The roots of the given polynomial p are determined and are returned as a vector of Complex elements. If the optional argument printRoots is set to true, the roots are also printed at once.

Example

import Modelica_LinearSystems2.Math.Polynomial;

x = Polynomial.x();
p1 = -6*x^2 + 4*x -3;

Polynomial.roots(p1);
// {0.333333 + 0.62361*j, 0.333333 - 0.62361*j}

Polynomial.roots(p1, true);
//  =
//    0.333333 + 0.62361*j
//    0.333333 - 0.62361*j
// {0.333333 + 0.62361*j, 0.333333 - 0.62361*j}

See also

Polynomial.numberOfRoots.

Interface

encapsulated function roots
  import Complex;
  import Modelica_LinearSystems2.ComplexMathAdds.Vectors;
  import Modelica_LinearSystems2.Math.Polynomial;
  input Polynomial p "Polynomial";
  input Boolean printRoots = false "True, if roots shall be pretty printed";
  output Complex result[:] = fill(Complex(0, 0), Polynomial.numberOfRoots(p)) "Roots of polynomial";
end roots;

Generated at 2024-12-17T19:26:02Z by OpenModelicaOpenModelica 1.24.3 using GenerateDoc.mos