horner
evaluates some polynomials or rationals for given values
Syntax
horner(P, x)
Arguments
- P
array of polynomials or of rationals.
- x
array of numbers, polynomials, or rationals.
Description
evaluates the polynomial or rational
matrix P = P(s)
when the variable s
of the
polynomial is replaced by x
:
horner(P,x)
=P(x)
Example (Bilinear transform): Assume P = P(s)
is
a rational matrix then the rational matrix
P((1+s)/(1-s))
is obtained by horner(P,(1+s)/(1-s))
.
To evaluate a rational matrix at given frequencies use
preferably the freq
primitive.
Examples
Evaluation of a polynomial:
P = poly(1:3, 'x', 'coeff') s = %s; horner(P, [1 2 ; 3 4]) // for real values horner(P, [1 2 ; 3 4]+%i) // for complex values horner(P, [1, s ; s^2, s^3]) // for polynomial values horner(P, [1/s, 1/s^2]) // for rational values
--> P = poly(1:3, 'x', 'coeff') P = 1 +2x +3x² --> s = %s; --> horner(P, [1 2 ; 3 4]) // for real values ans = 6. 17. 34. 57. --> horner(P, [1 2 ; 3 4]+%i) // for complex values ans = 3. + 8.i 14. + 14.i 31. + 20.i 54. + 26.i --> horner(P, [1, s ; s^2, s^3]) // for polynomial values ans = 6 1 +2s +3s² 1 +2s² +3s⁴ 1 +2s³ +3s⁶ --> horner(P, [1/s, 1/s^2]) // for rational values ans = 3 +2s +s² 3 +2s² +s⁴ --------- ---------- s² s⁴
Evaluation of some rationals:
[s,z] = (%s, %z); M = [1/s, (s-1)/s] horner(M, 1) horner(M, %i) horner(M, 2+s) horner(M, (2+z)/z) horner(M, [1, 1/z ; 2, (2+z)/z])
--> M = [1/s, (s-1)/s] M = 1 -1 +s - ----- s s --> horner(M, 1) ans = 1. 0. --> horner(M, %i) ans = 0. - i 1. + i --> horner(M, 2+s) ans = 1 1 +s ---- ---- 2 +s 2 +s --> horner(M, (2+z)/z) ans = z 2 ---- ---- 2 +z 2 +z --> horner(M, [1, 1/z ; 2, (2+z)/z]) ans = 1 z 0 1 -z - - - ---- 1 1 1 1 1 z 1 2 - ---- - ---- 2 2 +z 2 2 +z
See also
Report an issue | ||
<< hermit | Polynomials | hrmt >> |