Starting from:

$25

MA3457- Homework 2 Solved

Your assignment submission should contain a few files. You should submit all of your Matlab code and it should be properly commented to explain what the code is doing. You can submit as separate m-files saved as HW#Q# OR you can submit a single word or text file with all of the code pasted in (specifying or delineating code for each problem). For additional written work and discussion of problems, this should be a single pdf that is well-organized and either typed or neatly written. (If hand-written, use an app to scan and save as a single pdf). This file should be saved as HW#. To receive full credit on a problem, the code must run with no errors and the written work/discussion of the problem must also be complete. Matlab output should be discussed in the write-up.

Lagrange Interpolating Polynomials: Exploring function approximation at different data points or nodes.
For this problem, we will be looking at the following function,

) Main code. Create an m-file that will take D as an argument (the number of data points) and will will give PD, the (D − 1) degree Lagrange interpolating polynomial for f generated by D equally spaced nodes on the interval [−1,1]. You can generate the x values of the nodes with the command x = linspace(−1,1,D). You can then generate the f(x) values with the following command:
f = 1./(1+25.*x.^2)

You may modify/use any of the code posted on Canvas.

Generate plots of the data nodes, function f, and Lagrange interpolating polynomial P for D = 5, 10, 15, and 20. (Might be easiest to copy and paste each individual graph into one word file to then print out). Comment on what is happening. When plotting, we would like to plot the polynomial evaluated at additional points, xeval = linspace(−1,1,100).
 Generate a table or bar graph to examine the error, where error will be defined as:
for D = 5, 10, 15, 20

 What you are seeing is called Runge’s phenomenon. It happens with certain functionswhen we use Lagrangian interpolation with evenly spaced nodes. Why does it happen? Look at f(1), f0(1), f00(1), and f(3)(1). What happens to these derivatives, and what does that have to do with the error?
 Ways to choose nodes such that this effect is minimized have been developed. Onesuch choice of nodes are called Chebyshev nodes, where the nodes are not equally spaced and more nodes are closer to the endpoints. For the case D = 15, plot a graph of the Lagrangian interpolation using Chebyshev nodes and compare the error using Chebyshev nodes and equally spaced nodes. The Chebyshev nodes in the interval [-1,1] are:
Comment on the difference between the evenly spaced nodes/data points and the Chebyshev nodes.

1

Divided Differences:
Assuming that xr = xo + rh, verify directly (from the definition) the following special cases:

Note: These look very similar to approximations of derivatives that we will go over later in the course.

More products