Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Math 351 Assignment 4

Problem 1 - Newton interpolation and the Runge

(a) Write a function which computes, and returns, the interpolation polynomial using divided dierences. Let's

try not to use sympy this time, so the goal is as follows:

Input:

  x=[x0,...,xn]: a list of x coordinates

  y=[y0....,yn]: a list of y coordiantes

Output:

  a list a=[a0...a_n] representing the interpolation coecients in nested form.

(b) Write a function which evaluates polynomials in nested form.

Input:

x=[x0,...,xn]: a list of x coordinates

a=[a0....,an]: a list of interpolation coecients such as was computed in (a)

t, a real number

Output: the number p(t) given by

p(t) = a0  + (t x0 )(a1  + (t − x1 )(a2  + (t − x2 )(a3  + (t − x3 )(a4  + …)))))).

(c) Using parts (a) and (b), approximately reproduce Figure 4.7 (p.155) of the text, showing the Runge phenomenon. That is, you're going to interpolate the Runge function

f(x) =

at 9 equally spaced points in the interval [-5,5]. provide a graph which overlays the Runge function, the interpolation polynomial you compute, and a scatter plot of the interpolation nodes (xi , yi ) .

(d) Using parts (a) and (b), and also the problem from Assignment 3 in which we found the roots of the                Chebyshev Polynomials, reproduce gure 4.8 in the text. If you didn't complete that problem, you could also      look the roots up on wikipedia (https://en.wikipedia.org/wiki/Chebyshev_nodes). The claim is that if you put your interpolation points at the roots of Chebyshev polynomials (but spread out over the interval in question), the       interpolation errors are significantly better, though still not really that great.

Problem 2 - Richardson Extrapolation

In this problem, we're going to investigate how to best to choose the parameters N and h in the Richardson extrapolation algorithm.

(a) Implement Richardson Extrapolation as described in Algorithm 4.2 in the text. Leave ϕ , N, h as parameters, and return the entire triangular table of numbers D(i,j) (even though generally you would only use D(N, N),     that being the most exact value. If you like, you can try using Sympy's built-in richardson extrapolation function to test your work (though I myself have not done this).

(b) Use your results of (a) to compute the derivative of tan(x) numerically at some randomly chosen points in [0, 1]. Use N = 6 and pick a value of h which gives you accurate results without terrible oating point errors. You can compare with the value of sec2 (x) at those points, which is the true, exact derivative.

Problem 3 - Forward Euler and the Airy equation

In this problem, we'll solve, numerically, the dierential equation

y (t) + ty(t) = 0

subject to the initial conditions

y(− 10) = 0,    y(− 10) = 1.0 ⋅ 10−9.

This is basically the Airy equation (https://en.wikipedia.org/wiki/Airy_function#Denitions), except wikipedia's x variable is my t. This is a good toy problem for many possible projects, in which you solve other DEs.

(a) First we'll work out the algebra for how to do this. Since it's a SECOND order DE, use the following trick: let z = y, so that z = y. Now there's a system of 2 DEs, both fi rst-order:

 

and the initial conditions are on y(− 10) and z(− 10). Work out the algebra for how to solve this system of        equations numerically using the forward Euler method: approximate the derivatives by y(t) =  and  similarly for z, then solve for y(t + h) and z(t + h) in terms of stuff you've computed already. Show your work.

(b) Implement your scheme using numpy, and then plot a graph of the solution over the interval [ − 10, 10] using a step size of h = 0.01 (so there'll be 2001 points in the plot).

(c) Interestingly there's actually a choice you could make in part (b). If you compute y(t + h) before computing z(t + h), then every time you compute z(t + h), you could use either

  the new value of y: y(t + h), or

  the old value of y: y(t).

Since h is small, both of these more or less mean "the current value of y", so it's not really clear which choice is better. However, one choice IS better! Based on the wikipedia article I've linked above and/or other results         about the solutions to the Airy equation, which one seems to give better results? And why do you think this       might be?

n [ ]: