functionroots
Determine zeros of polynomial, i.e., points x with p(x)=0
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
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| Polynomial | p | Polynomial | |
| Boolean | printRoots | false | True, if roots shall be pretty printed |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Complex[:] | result | fill(Complex(0, 0), Polynomial.numberOfRoots(p)) | Roots of polynomial |