Polynomial definition from given roots or coefficients, or characteristic to a square matrix.
p = poly(vec, vname) p = poly(vec, vname, "roots"|"coeff") Pc = poly(matNN, vname)
a string: the symbolic variable name of the polynomial. Allowed characters are the same as for variables names (see naming rules).
scalar, vector, or non-square matrix of real or complex numbers.
Indicates what numbers in vec
represent.
"roots"
is the default value.
Shortcuts can be used: "r"
for "roots"
,
and "c"
for "coeff"
.
Polynomial with given roots or coefficients and symbolic variable name.
Square matrix of real or complex numbers.
Characteristic polynomial of the given square matrix,
= det(x*eye() - matNN)
, with the symbolic variable
x = poly(0,vname)
.
vec
is provided,
p = poly(vec, "x", "roots")
or
p = poly(vec, "x")
is the polynomial
whose roots are the vec
components, and
"x"
is the name of its variable.
![]() |
|
The simple expression x=poly(0,"x")
defines the
elementary p(x)=x
, which then can be used with
usual operators +, -, *, / and simple functions like
sum()
.
![]() | Scilab provides 3 predefined elementary polynomials
%s , %z , and
$ . The last one is mainly used as symbolic
value of last index (of a range). |
poly(vec, "x", "coeff")
builds the polynomial
with symbol "x"
whose coefficients in order of
increasing degree are vec
components
(vec(1)
is the constant term of
the polynomial). Null high order coefficients (appended to
vec
) are ignored.
![]() | Conversely, coeff(p) returns the coefficients
of a given polynomial. |
matNN
is provided,
poly(matNN, vname)
returns its characteristic polynomial
of symbolic variable vname
, i.e. p
is set
to det(x*eye() - matNN)
, with x = poly(0,vname)
.
Building a polynomial of given coefficients:
// Direct building: x = poly(0, "x"); p = 1 - x + 2*x^3 // With poly(): p2 = poly([1 -1 0 2], "x", "coeff") // With null high order coefficients p3 = poly([2 0 -3 zeros(1,8)], "y", "coeff") | ![]() | ![]() |
--> p = 1 - x + 2*x^3 p = 3 1 -x +2x --> p2 = poly([1 -1 0 2], "x", "coeff") p2 = 3 1 -x +2x --> p3 = poly([2 0 -3 zeros(1,8)], "y", "coeff") p3 = 2 2 -3y
Building a polynomial of given roots:
// Direct building: x = poly(0,"x"); p = (1-x)^2 * (2+x) // With poly(): p2 = poly([1 1 -2], "x") // With infinite roots p3 = poly([%inf -1 2 %inf -%inf], "x") | ![]() | ![]() |
--> p = (1-x)^2 * (2+x) p = 3 2 -3x +x --> p2 = poly([1 1 -2], "x") p2 = 3 2 -3x +x --> p3 = poly([%inf -1 2 %inf -%inf], "x") p3 = 2 -2 -x +x
Characteristic polynomial of a square matrix:
--> A = [1 2 ; 3 -4] A = 1. 2. 3. -4. --> poly(A, "x") ans = 2 -10 +3x +x
Version | Description |
5.5.0 | The only values allowed for the third argument are "roots", "coeff", "c" and "r". |
6.0.0 | The name of the symbolic variable is no longer limited to 4 characters. It can include some extended UTF-8 characters. |
6.0.2 | With the "coeff" method, null high order coefficients are now ignored. |