Task 06

Task 06ΒΆ

deadline: 11/04/2021 23:59 CET

[0.5 points]: Write a function that calculates natural cubic spline interpolation of a given set of data points \( (x_i, y_i) \), \( i = 0, 1, \dots, n - 1 \). The function returns a list of cubic splines in the form of numpy.poly1d so that the \( i \)-th element of the list is the cubic spline interpolation in the interval \( [x_{i}, x_{i + 1}] \).

[0.5 points]: Calculate the natural cubic spline interpolation of the following set of data points,

\[ (0, 0), \ (1, 2), \ (2, -1), \ (3, 1) \]

and plot the result. You may evaluate the correctness of your implementation using the scipy.interpolate.CubicSpline function with the bc_type="natural" input argument.

# add your code here