Anonymous user
Horner's rule for polynomial evaluation: Difference between revisions
Horner's rule for polynomial evaluation (view source)
Revision as of 19:45, 31 October 2010
, 13 years agoPari/GP
(Pari/GP) |
|||
Line 449:
in
{Show {Horner [~19 7 ~4 6] 3}}</lang>
=={{header|PARI/GP}}==
Also note that Pari has a polynomial type. Evaluating these is as simple as <code>polsubst(P,variable(P),x)</code>.
<lang>horner(v,x)={
my(s=0);
forstep(i=#v,1,-1,s=s*x+v[i]);
s
};</lang>
=={{header|Perl}}==
|