WOLFRAM SYSTEM MODELER
rootsCompute zeros of a polynomial where the highest coefficient is assumed as not to be zero |
SystemModel["Modelica.Math.Vectors.Utilities.roots"]
This information is part of the Modelica Standard Library maintained by the Modelica Association.
r = Vectors.Utilities.roots(p);
This function computes the roots of a polynomial P of x
P = p[1]*x^n + p[2]*x^(n-1) + ... + p[n-1]*x + p[n+1];
with the coefficient vector p. It is assumed that the first element of p is not zero, i.e., that the polynomial is of order size(p,1)-1.
To compute the roots, the eigenvalues of the corresponding companion matrix C
|-p[2]/p[1] -p[3]/p[1] ... -p[n-2]/p[1] -p[n-1]/p[1] -p[n]/p[1] | | 1 0 0 0 0 | | 0 1 ... 0 0 0 | C = | . . ... . . . | | . . ... . . . | | 0 0 ... 0 1 0 |
are calculated. These are the roots of the polynomial.
Since the companion matrix has already Hessenberg form, the transformation to Hessenberg form has not to be performed.
Function eigenvaluesHessenberg
provides efficient eigenvalue computation for those matrices.
r = roots({1,2,3}); // r = [-1.0, 1.41421356237309; // -1.0, -1.41421356237309] // which corresponds to the roots: -1.0 +/- j*1.41421356237309
p |
Type: Real[:] Description: Vector with polynomial coefficients p[1]*x^n + p[2]*x^(n-1) + p[n]*x +p[n-1] |
---|
roots |
Default Value: fill(0, max(0, size(p, 1) - 1), 2) Type: Real[max(0, size(p, 1) - 1),2] Description: roots[:,1] and roots[:,2] are the real and imaginary parts of the roots of polynomial p |
---|