Description
Hermite and Newton’s Divided Difference Interpolation
i. Open the colab file shared in BUX.
ii. Create a copy of that shared file in your drive.iii. Rename the colab filename using the format Name-ID-Lab Section
Lab Introduction
Part 1: Hermite Interpolation
For the case of Hermite Interpolation, we look for a polynomial that matches both f′(xi) and f(xi) at the nodes xi=x0,…,xn . Say you have n+1 data points, (x0,y0),(x1,y1),x2,y2),…,(xn,yn) and you happen to know the first-order derivative at all of these points, namely,
(x0,y′0),(x1,y′1),(x2,y′2),…,(xn,y′n) . According to hermite interpolation, since there are 2n+2 conditions; n+1 for f(xi) plus n+1 for f′(xi) ; you can fit a polynomial of order 2n+1 .
Part 2: Newton’s Divided Difference Interpolation
[Task 1] – 4 marks
Function l(k, x) has already been defined for you.
You have to implement the functions: h(k, x) and h_hat(k, x) and hermit(x, y, y_prime)
First two methods implement the Hermit Basis to be used for interpolation using Hermite Polynomials and third method calculates the Hermite polynomial from a set of given nodes and their corresponding derivatives.
You will have to remove the “raise NotImplementedError()”.
[Task 2] – 3 marks
the calc_div_diff(x,y) function to calculate the divided differences.
2. You have to implement the __call__() function which takes an input x, and calculates y using all the difference coefficients. x can be a single value or a numpy. In this case, it is a numpy array. You will have to remove the “raise NotImplementedError()” .
[Task 3]- 1.5 marks
Problem related Newton’s Divided Difference interpolation:
Suppose, you have three nodes (-0.5, 1.87), (0, 2.20), (0.5, 2.44). Using Newton’s
Divided Difference method, print out the value of the interpolating polynomial at x = 6.
You have to solve the given problem using Newtons_Divided_Differences class.
[Task 4]- 1.5 marks
Problem related Hermite interpolation:
Suppose, consider the following data set:
Using Hermit basis, print out the interpolating polynomial and find the value at x = [0.15,0.30,0.50].
You have to solve the given problem using hermit function.
Reviews
There are no reviews yet.