Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2025.0.0 - 日本語


poly

Polynomial definition from given roots or coefficients, or characteristic to a square matrix.

Syntax

p = poly(vec, vname)
p = poly(vec, vname, "roots"|"coeff")
Pc = poly(matNN, vname)

Arguments

vname

a string: the symbolic variable name of the polynomial. Allowed characters are the same as for variables names (see naming rules).

vec

scalar, vector, or non-square matrix of real or complex numbers.

flag "roots" (default) | "coeff" (or "r" | "c")

Indicates what numbers in vec represent. "roots" is the default value.

Shortcuts can be used: "r" for "roots", and "c" for "coeff".

p

Polynomial with given roots or coefficients and symbolic variable name.

matNN

Square matrix of real or complex numbers.

Pc

Characteristic polynomial of the given square matrix, = det(x*eye() - matNN), with the symbolic variable x = poly(0,vname).

Description

When a vector or non-square matrix 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.

    • degree(p)==length(vec)
    • poly() and roots() are then inverse functions of each other.
    • Infinite roots give null highest degree coefficients. In this case, the actual degree of p is smaller than length(vec). For instance, poly([-%inf -1 2 %inf ], "x") yields (x-2)(x+1) whose degree is 2.

    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.
When a square matrix 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).

Examples

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]
poly(A, "x")
--> A = [1 2 ; 3 -4]
 A  =
   1.   2.
   3.  -4.

--> poly(A, "x")
 ans  =
            2
  -10 +3x +x

See also

  • inv_coeff — 係数を指定して多項式行列を作成
  • coeff — 多項式行列の係数
  • roots — 多項式の根
  • varn — 多項式または有理分数のシンボリック変数
  • horner — 多項式/有理数の評価
  • %s — 多項式を定義する際に使用される変数.
  • %z — 多項式を定義する際に使用される変数.
  • rational — Scilab オブジェクト, Scilabの有理数
  • rlist — Scilab 有理関数定義

History

バージョン記述
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.
Report an issue
<< polfact Polynomials polyDisplay >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Oct 24 11:17:41 CEST 2024