Math Programming Exercise Assignment
Use the finite difference method to approximate the solution of the Poisson problem:
-?u := -∂xxu - ∂yyu = f, in ? = (0, 1) × (0, 1),
u = 0 , on ∂?,
where f is a given function. Specifically, solve the approximation problem
where n ≥ 2 is an integer, h := 1/n, fi,j := f (ih, jh), and wi,j ≈ u(ih, jh). The object wi,j is a called a grid function. It is a discrete approximation of the continuous variable u. This approximation problem can be written as a linear system Aw = f, where A is an (n - 1)2 × (n - 1)2 matrix.
Write a code in Matlab to solve the approximation problem Aw = f using five different iterative schemes: (a) Jacobi, (b) Gauss-Seidel, (c) relaxation, (d) Steepest Descent, (e) Conjugate Gradient, and, finally, (f) preconditioned Steepest Descent using the incomplete Choleski factorization of A.
You should not explicitly form the stiffness matrix A. Instead, if you need to compute a matrix vector multiplication Ax, where x is an arbitrary vector, you should instead use the stencil form as above. In other words, translate x into a grid function with zero boundary values.
The methods above are iterative. They only stop iterating when you supply a stopping tolerance. For this use
where wi,j(k) is the kth iterate and τ is the stopping tolerance, which you should make an input parameter for your code. Compute and plot Rk for each iteration.
In your tests, use n = 64 and n = 128, wi,j(0) = 0, and
f(x, y) = sin3(3πx)cos(πy).
Plot your final iterate for each method.