[Scilab-users] Evaluating a polynomial on a square matrix

Dang Ngoc Chan, Christophe Christophe.Dang at sidel.com
Tue Sep 24 10:03:10 CEST 2019


I'm aware that this is an inefficient way to compute the result
but unfortunately, the Horner form of polynomial does not work on matrices:

(A + 2)*A is not the same as A*A + 2*A for Scilab.

It is possible to write a better function manually,
by first calculating the successive powers before applying coefficients and adding them.

It is probably possible to create such functions automatically
by concatenating strings but it is not straightforward.

HTH,

regards

> stringP = "Y = "+string(C(1))
>
> for i = 2:n
>     stringP = stringP+" + "+string(C(i))+"*x^"+string(i-1) end
>
> deff("[Y] = fctP(x)", stringP) \\ creation of the function corresponding to the
> polynomial

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer

General
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


More information about the users mailing list