.Spot.Base.Math.polyRoots

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) := Spot.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

Interface

function polyRoots
  extends Icons.Function;
  input Real[:] c "coefficient vector";
  output Real[size(c, 1) - 1, 2] r "root vector, 2nd index=1:2, real and imaginary part";
  output Integer N0 "true deg of polynomial = number of valid roots (r[1:N0,:])";
end polyRoots;

Generated at 2024-04-26T18:16:04Z by OpenModelicaOpenModelica 1.22.3 using GenerateDoc.mos