functionpolyRoots
Roots of a polynomial
Extends from Modelica.Icons.Function (Icon for functions).
Information
The function determines the root vector r of a polynomial of degree N with coefficient vector c.
c_0 + c_1*x + c_2*x^2 + ... + c_N*x^N
The resulting n roots are r[k, 1:2], k=1 .. n.
r[k, 1]: real part of kth root r[k, 2]: imaginary part of kth root
If c_N is different from 0 then n=N, otherwise n< N.
Example
Real[3] c = {1,2,3}; Real[2,2] r; algorithm (r, n) := PowerSystems.pu.Functions.roots(c);
The resulting n = 2 roots are:
r[1,:] = {-0.333333 +0.471405}; r[2,:] = {-0.333333 -0.471405};
See also polyCoefReal, polyCoef, eigenValues
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real | c | coefficient vector |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real | r | root vector, 2nd index=1:2, real and imaginary part | |
| Integer | N0 | true deg of polynomial = number of valid roots (r[1:N0,:]) |