Important: run the code cell below once when you just opened this notebook! It will make sure that plotting is enabled.
# some setup
%matplotlib inline
import numpy as np # makes numpy routines and data types available as np.[name ouf routine or data type]
import matplotlib.pyplot as plt # makes plotting command available as plot.[name of command]
Plot the Dirichlet and Fejér kernel for various values of n. Also generate a plot where you plot both kernels in one diagram.
# Code for Dirichlet plots
#code for Fejer plots
This exercise is about interpolation with the Gauss kernel $k(x,y)=\exp(-\gamma\|x-y\|_2^2)$.
a) You are given a set of sampling points $X = \{x_1,\dots,x_n\}$ with $x_i \in \mathbb R^2$ and function values at these points $f|_X = \{f(x_1),\dots,f(x_n)\}$. Write some code which solves $$ A_{X,X}\alpha = f|_X, $$ where $A_{X,X} = (k(x_i,x_j))_{i,j=1,\dots,n}$ is the kernel matrix. You can use any of the linear algebra routines that come along with numpy. Also write a subroutine which evaluates the interpolant $s_{X,f|_X} = \sum_{j=1}^n \alpha_j k(x_j,\cdot)$ at a given set of points $\{y_1,\dots,y_m\}$.
# your code goes here
b) For each of the following type of sampling points, write a subroutine which generates, for given $m \in \mathbb N$, $m^2$ sampling points:
For the Halton sequence you can use the ghalton package. It is not in the conda package index, but in the pip package index.
# Uniform grid points
# tensor-product Chebyshev points
# Halton points
c) Use your code to interpolate the function $$ f(x,y) = 3(1-x)^2 \exp(-x^2 - (y+1)^2)\
|f(y) - s_{X,f|X}(y)| $$ for each of type of sampling points. To this end, evaluate $f$ and $s{X,f|_X}$ on a uniform grid with mesh size $1/1000$.
# your code goes here
d) For each the sampling points used in c) plot the power function $$ P_X^2(x) = k(x,x) - k(x,\cdot)(x) $$ Again, use a uniform grid with mesh size $1/1000$ to generate the plots. Compare the plots with the plots obtained in c).
# your code goes here