- 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 Runges 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
- (6 points) 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.
Reviews
There are no reviews yet.