The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 4 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
as3.dvi
(a) First write a routine that does the following: given an interval [a,b], a function F, and a number n, your code should produce the following three interpolants to the function F: (i) a polynomial interpolant to F at n equidistant points on [a,b]; (ii) a polynomial interpolant at n Chebyshev points of that interval; (iii) a cubic spline interpolant at n equidistant points. You are allowed to look at our class demo subdir, but you must document this fact (and you may not use the matlab library, such as polyfit). Furthermore, the polynomial interpolation must be done via a table of divided differences.
In order to produce the spline interpolant, you may use the matlab library. With x the set of your interpolation points, and y the values of F at these points, you may use the sequence p=spline(x,y);
s=ppval(z,p);
The vector s then contains the values of your spline interpolant at the points specified in z. This is equivalent to the single command
s=spline(x,y,z);
(b) Now, run your code with different values of n ≤ 25, with respect to each of the four functions that appear in Q. 3. Try to find values of n that allow you to make observations (of the sort: ‘the spline interpolant is much worse than each of the polynomial interpolants’, or ‘There is a major improvement by switching to Chebyshev points’, etc.). For each function, select two values of n for which you are able to make the most significant observations.
(c) Turn in your well-documented code, the eight outputs (two values of n for each of the four functions), and the observations you were able to make. Compare these observations with your predictions in the previous question. Here, ‘output’ must include a plot of the error functions, and some (2-3) of the divided difference tables that your code produced.
In contrast with previous assignments, we will examine in this question the quality of your code. Namely, writing a compact efficient code is desired.