Anonymous user
Horner's rule for polynomial evaluation: Difference between revisions
Horner's rule for polynomial evaluation (view source)
Revision as of 22:17, 9 August 2010
, 13 years ago→{{header|MATLAB}}
(Added a solution for MATLAB) |
|||
Line 289:
Output:
<lang MATLAB>>> hornersRule(3,[-19, 7, -4, 6])
ans =
128</lang>
Matlab also has a built-in function "polyval" which uses Horner's Method to evaluate polynomials. The list of coefficients is in descending order of power, where as to task spec specifies ascending order.
<lang MATLAB>>> polyval(fliplr([-19, 7, -4, 6]),3)
ans =
|