Previous Up Next

6.28.21  Évaluer un polynôme : horner

si horner a deux paramètres : un polynôme P donné sous forme symbolique ou par la liste de ses coefficients et un nombre a.
horner renvoie P(a) calculé par la méthode de Hörner.
On tape :

horner(x^2-2*x+1,2)

ou :

horner([1,-2,1],2)

On obtient :

1

On peut mettre un troisième argument optionnel pour indiquer la variable à remplacer, par exemple

horner(y^2-2*x*y+1,2,y)

Si horner a trois paramètres : deux listes ak et xk et un nom de variable par exemple x.
horner évalue un polynome d’interpolation en x à partir des différences divisées ak et des xk (cf 6.28.33).
On tape :

horner([15,9,0,2],[1,2,3,4],x)

On obtient :

(2*(x-3)*(x-2)+9)*(x-1)+15

On tape :

simplify((2*(x-3)*(x-2)+9)*(x-1)+1 )

On obtient :

-6+31*x-12*x^2+2*x^3

On vérifie, en utilisant la commande lagrange.
Si P(x):=−6+31*x−12*x2+2*x3, on a
[P(1),P(2),P(3],P(4)]=[15,24,33,54]
On tape :

lagrange([1,2,3,4],[15,24,33,54],x)

On obtient :

(2*(x-3)*(x-2)+9)*(x-1)+15

On tape :

lagrange([1,2,3,4],[15,24,33,54],lagrange)

On obtient les différences divisées de P :

[15,9,0,2]

Previous Up Next