Write code to evaluate the polynomial at the point indicated by using Horner’s algorithm.
p(x)=x^5−x^4−3x^3−5x^2+10 at x=2
(use MATLAB to code and show the results.)
Required Matlab code with explanatory comments is given below:
function x = Q_horner(a,z)
n = length(a); %length of polynomial vector coefficients
result = a(1); %initialize result
for j = 2:n
result = result*z + a(j); %horner's
substitution
end
x = result; %output result
Result:
Hope this was helpful. Please do leave a positive rating if you liked this answer. Thanks and have a good day!
Get Answers For Free
Most questions answered within 1 hours.