Multigrid Method for Solving Ax = b

Implementation of the Multigrid Method (MG) for solving Ax = b, uses Gauss-Seidel or Jacobi for smoothing. Includes V, W, and F cycle
392 téléchargements
Mise à jour 5 fév. 2023

Afficher la licence

Multigrid Method (MG) for solving Ax = b is best described in the wiki article:
  1. Pre smoothing is preformed on the A matrix, GS or Jacboi
  2. Residual error is computed and downsampled to a coarser grid
  3. Coarser grid is solved through recursion of multirgird function
  4. Prolongation of correction is interpolated from the coarse grid to the original matrix
  5. Post smoothing is preformed on the A matrix, GS or Jacobi
  6. Repeat until converged or max iterations
This can be one of the fastest methods to solve Ax = b, and can even be O(n). However, this particle code isn't the fastest. This is best for learning how the method works.
V,W,F cyle are different ways to go through the grids, V has fast iterations but slow converagnce, F has slower iterations but faster converance, and W has slowest iterations but fastest convergance. Refer to wiki for a in depth explanation.
I followed the explanation given by Gilbert Strang for how to build the code:
Function gives you options for number of pre and post smoothing iterations, type of cycle (V,W,F), smoother type (Gauss-Seidel,Jacobi), amount of grid levels, max iterations, and tolerance.
Jacoobi is faster than Gauss-Seidel due to MATLAB's coding language however Gauss-Seidel is prefered as it is more stable.
Test scripts are provided to play around with the function.
This is the fastest and simpliest MG method for MATLAB I have seen. If you have any way to improve it please let me know

Citation pour cette source

Benjamin Beaudry (2025). Multigrid Method for Solving Ax = b (https://fr.mathworks.com/matlabcentral/fileexchange/123145-multigrid-method-for-solving-ax-b), MATLAB Central File Exchange. Extrait(e) le .

Compatibilité avec les versions de MATLAB
Créé avec R2022b
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Publié le Notes de version
1.1.2

fixed typo

1.1.1

added A_b.mat file, added authors name

1.1.0

fixed bug in F and W cycle

1.0.0