matlab code

profileA999
Project5.pdf

MATH466/462 Project 5. Due in class on Wed, April 22, 2020 Instruction: your project report should include necessary mathematical justification, description, and details of your algorithms/conclusions. Your MATLAB codes and generated outputs may be attached in the end of the report. Make sure you addressed all the questions in each problem. Both the report and codes will be graded. Please submit a printed hard-copy. Problem A (20 pts): Geometric Multigrid Method For solving large-scale discretized ODE and PDE systems, the classical iterative methods (such as Jacobi, Gaussian-Seidel, SOR, PCG) are attractive since they can make best use of the sparsity to reduce operation costs. However, these methods often show slower convergence rates when the mesh step size gets smaller (i.e. system size becomes larger). To achieve mesh-independent convergence rates, the Geometric and Algebraic Multigrid methods are often the best choice since they usually have the optimal linear 𝑂(𝑁) time complexity if they work out well. This project will show you the super power of multigrid method.

Task 1: Consider the ODE BVP (compare with Example 7.8)

9𝑦′′(𝑥) + 𝜋2𝑦(𝑥) = 0, 𝑦(0) = −1, 𝑦(3/2) = 3

with the exact solution 𝑦(𝑥) = 3 sin(𝜋𝑥/3) − cos(𝜋𝑥/3). Discretize the ODE using central-difference scheme with a mesh step sizeℎ = 1/𝑁 and then solve the resulting system 𝐴ℎv = fℎ using backslash direct solver. Compute the maximum-norm error 𝐸ℎ of finite difference solutions with 𝑁 = 100, 200, 400, 800, 1600 and use loglog to plot the errors 𝐸ℎ as a function of 𝑁 . What slope of the line do you observe?

Task 2: Solve the linear system 𝐴ℎv = fℎ with 3 different iterative solvers: Jacobi, Gauss-Seidel, and Conjugate-Gradient methods. For a given tolerance 10−7, compare their used iteration numbers 𝑖𝑡𝑁 with respect to different mesh sizes 𝑁 = 100, 200, 400, 800, 1600.

• (1) For each method, use semilogx to plot the iteration numbers 𝑖𝑡𝑁 as a function of 𝑁 . What slopes do you observe? Are their convergence rates getting slower?

• (2) For each method, use semilogy to compare the relative residual norms as a function of iteration numbers for different 𝑁 = 100, 200, 400, 800, 1600. What you observe in the first few iterations?

Task 3: Modify the given 1D Geometric Multigrid codes (based on V-cycle) to solve the above ODE BVP. (a) Study the algorithm from slide (a comment video will be provided): https://www.math.ust. hk/%7Emawang/teaching/math532/mgtut.pdf (b) Read and understand this 1D codes (with many comments within codes): https://github. com/dappelha/MultiGridMatlab/tree/master/1DMultigridTutorial (c) More detail check Chapters 1-3 of tutorial book (skip theory): http://www.math.ust.hk/ %7Emamu/courses/531/tutorial_with_corrections.pdf For a given tolerance 10−7, compare their used V-cycle iteration numbers 𝑖𝑡𝑁 for different mesh sizes 𝑁 = 100, 200, 400, 800, 1600.

• (1) use semilogx to plot the V-cycle iteration numbers as a function of different mesh sizes 𝑁 = 100, 200, 400, 800, 1600. What do you observe?

• (2) use semilogy to compare the relative residual norms as a function of V-cycle iteration numbers for different 𝑁 = 100, 200, 400, 800, 1600. What do you observe?

1