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
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.