Читать книгу Solutions Manual to Accompany An Introduction to Numerical Methods and Analysis - James F. Epperson - Страница 11
Chapter 2 A SURVEY OF SIMPLE METHODS AND TOOLS 2.1 HORNER'S RULE AND NESTED MULTIPLICATION Exercises:
Оглавление1 Write each of the following polynomials in nested form.;;;.Solution:;;;.
2 Write each of the following polynomials in nested form, but this time take advantage of the fact that they involve only even powers of to minimize the computations.;.
3 Write each of the following polynomials in nested form.;;.Solution:;;.
4 Write a computer code that takes a polynomial, defined by its coefficients, and evaluates that polynomial and its first derivative using Horner's rule. Test this code by applying it to each of the polynomials in Problem 1.Solution: The following is a MATLAB script which does the assigned task, using the less efficient approach to computing the derivative.function [y, yp] = horner1(a,x) n = length(a); y = a(n); for k=(n-1):(-1):1 y = a(k) + y*x; end % yp = (n-1)*a(n); for k=(n-1):(-1):2 yp = (k-1)*a(k) + yp*x; end
5 Repeat the above, using the polynomials in Problem 2 as the test set.Solution: The same script can be used, of course.
6 Repeat the above, using the polynomials in Problem 3 as the test set.
7 Consider the polynomialThis can be written in “nested‐like” form by factoring out each binomial term as far as it will go, thus:Write each of the following polynomials in this kind of nested form.;;.Solution:;.
8 Write a computer code that computes polynomial values using the kind of nested form used in the previous problem, and test it on each of the polynomials in that problem.
9 Write a computer code to do Horner's rule on a polynomial defined by its coefficients. Test it out by using the polynomials in the previous problems. Verify that the same values are obtained when Horner's rule is used as when a naive evaluation is done.
10 Write out the Taylor polynomial of degree 5 for approximating the exponential function, using , using the Horner form. Repeat for the degree 5 Taylor approximation to the sine function. (Be sure to take advantage of the fact that the Taylor expansion to the sine uses only odd powers.)Solution: For the exponential function, we getfor the sine function we get
11 For each function in Problem 11 of §1.1, write the polynomial approximation in Horner form, and use this as the basis for a computer program that approximates the function. Compare the accuracy you actually achieve (based on the built‐in intrinsic functions on your computer) to that which was theoretically established. Be sure to check that the required accuracy is achieved over the entire interval in question.
12 Repeat the above, except this time compare the accuracy of the derivative approximation constructed by taking the derivative of the approximating polynomial. Be sure to use the derivative form of Horner's rule to evaluate the polynomial.