Mathematical Modelling with Python. Please only answer if you can assist with all parts. Many thanks.
Write a Python function called InterpolateLagrange that finds an approximation based on the nth Lagrange interpolating polynomial of n + 1 data points. It should take the x and y values of the data points as inputs, as well as the x value of the desired approximation. It should then return the corresponding approximation of the y value.
```python
def InterpolateLagrange(x, y, xval):
# usage: Interpolatelagrange(x, y, x: array of x-values, y: array of y-values e.g.: x=np.array([0,0.5,1,1.5,2]), y=np.array([1,1.2,1.4,1.7,2.2]), xval: x-value, for which the y-value should be obtained e.g.: xval=1.25
# output: yval: y-value
# YOUR CODE HERE
```
The data below is population data from past censuses.
```python
year = np.array([1841.,1851.,1861.,1871.,1881.,1891.,1901.,1911.,1926.,1936.,1946.,1951.,1956.,1961.,1966.,1971.,1979.,1981.,1986.,1991.,1996.,2002.,2006.,2011.])
pop = np.array([6528799.5111557.,4402111.4053187.,3870020.,3468694.,3221823.,3139688.,2971992.,2968420.,2955107.,2960593.,2898264.,2818341.,2884002.,2978248.,3368217.,3443405.,3540643.,3525719.,3626087.,3917203.,4239848.,4588252.])
```
Using the Lagrange interpolation, give an approximation for the population in Ireland in 1868? Try a few other years too.
```python
# YOUR CODE HERE
```
Now try using cubic spline interpolation. You will create a Python function called InterpolateCubic that finds the coefficients of the cubic splines using the Gauss-Seidel method.
First, create a Python function called GaussSeidel that solves a system of linear equations. Print the approximate error at each iteration. Let the initial guess be a zero vector. The function should return the solution as an array x.
```python
def GaussSeidel(A, b, TOL, N):
# Gauss-Seidel method for systems of linear equations
# Parameters
# A: nxn matrix
# b: vector of right-hand side
# TOL: tolerance
# N: maximum number of iterations
# Returns
# x: approximate solution to Ax = b or 'Maximum number of iterations exceeded'
# Usage
# >>> GaussSeidel(A, b, TOL, N)
# YOUR CODE HERE
```