Home /
Expert Answers /
Computer Science /
please-answer-7-a-b-c-7-use-matlab-to-fit-various-piecewise-polynomials-to-the-runge-function-usin-pa709
(Solved): please answer 7 a,b,c 7. Use MATLAB to fit various piecewise polynomials to the Runge function, usin ...
please answer 7 a,b,c
7. Use MATLAB to fit various piecewise polynomials to the Runge function, using the same nodes as in part (a) of exercise 4. (a) Find the piecewise linear interpolant of f(x). (You may use MATLAB routine interp1 or write your own routine. Type help interp1 in MATLAB to find out how to use interp1.)
(b) Find the piecewise cubic Hermite interpolant of f(x). (Write your own routine for this, using formulas (8.17) and (8.18).) (c) Find a cubic spline interpolant of f(x). (You may use either the interp1 command or the spline command in MATLAB.) In each case above, plot f(x) and the interpolant on the same graph. If you wish, you can put all of your graphs on the same page by using the subplot command.
4. (a) Use MATLAB to fit a polynomial of degree 12 to the Runge function f(x)=1+x21?, interpolating the function at 13 equally-spaced points between -5 and 5. (You can set the points with the command x=[?5:5/6:5];.) You may use the MATLAB routine polyfit to do this computation or you may use your own routine. (To find out how to use polyfit type help polyfit in MATLAB.) Plot the function and your 12th-degree interpolant on the same graph. You can evaluate the polynomial at points throughout the interval [?5,5] using MATLAB's polyval routine, or you may write your own routine. Turn in your plot and a listing of your code.