Consider two polynonials a(z) = -ook rn-k with a, e R, k = 0 : n and b (z) _ -o
ID: 3598676 • Letter: C
Question
Consider two polynonials a(z) = -ook rn-k with a, e R, k = 0 : n and b (z) _ -o krm-k with , e C, k 0 : m and write efficient Matlab code that uses Horner's rule in order to compute a(2)60) (r) with r E C. Test your code on a, b and lr given in the provided Matlab data file InpHorner.ab. Recall that an algorithm is efficient when it is fast, it is not wasteful of storage and does not produce unnecessarily inaccurate results. For the given data the answer is a(2) ob(1) (x) =-(46.039 + 2.4881i) × 102 rounded to five significant digits Your hand out should include a brief theoretical discussion of how you proceed along with your code and its results. While testing your code you may find useful the build-in matlab function polyval.Explanation / Answer
%Assumes that the polynomial coefficients are stored in the array a(j),
%j = 0..n. dp = value of derivative %upon completion
a = (0:n)
dp = n*a(n+1)
for k = n-1:-1:1
dp = k*a(k+1) + dp*x
end