projects / proj-math-016
Next task →
Projects/Foundations/Finite-difference Poisson solver on a 2D grid — real-data stress test
Level 3 · intermediate · ~10 h

Finite-difference Poisson solver on a 2D grid — real-data stress test

Solve the Poisson equation with Dirichlet boundary conditions using Jacobi, Gauss-Seidel and multigrid V-cycles, and compare convergence rates. Repeat on a real dataset, report a table with confidence intervals over three trials, and explain which assumption broke.
Add to portfolio →

Problem statement

  • 01Solve the Poisson equation with Dirichlet boundary conditions using Jacobi, Gauss-Seidel and multigrid V-cycles, and compare convergence rates. Repeat on a real dataset, report a table with confidence intervals over three trials, and explain which assumption broke.

Real-world motivation

  • 01The discrete Laplacian is the bridge between calculus and iterative linear solvers; multigrid shows why local smoothing is not enough. The real-data stress test setting forces concrete choices about data, scale and evaluation.

Learning objectives

  • 01Discretize the Laplacian
  • 02Implement three solvers
  • 03Verify the discrete maximum principle
  • 04Report wall-clock seconds on one pinned CPU core alongside the baseline metrics.

Technical architecture

  • 01five-point stencil
  • 02red-black Gauss-Seidel ordering
  • 03geometric multigrid with bilinear restriction

Mathematical foundations

  • 01$\frac{u_{i+1,j}-2u_{ij}+u_{i-1,j}}{h^2}+\frac{u_{i,j+1}-2u_{ij}+u_{i,j-1}}{h^2}=f_{ij}$
  • 02Jacobi spectral radius $\cos(\pi h)$

Dataset and sources

  • 01MNIST 70k subset
  • 02UCI Sparse Matrix collection

Step-by-step tasks

  • 01Frame the task and freeze the real-data stress test evaluation protocol with a fixed random seed.
  • 02Implementation 1: Vectorize stencil updates with numpy slices
  • 03Implementation 2: Implement V-cycle with restriction and prolongation
  • 04Implementation 3: Use the manufactured solution u=sin(pi x)sin(pi y)
  • 05Verification 1: Check discrete residual decreases
  • 06Verification 2: Verify max principle for f=0
  • 07Run the ablation grid and report wall-clock seconds on one pinned CPU core over three independent trials.

Implementation requirements

  • 01Vectorize stencil updates with numpy slices
  • 02Implement V-cycle with restriction and prolongation
  • 03Use the manufactured solution u=sin(pi x)sin(pi y)
  • 04Log all hyperparameters and the random seed for the real-data stress test run.

Testing requirements

  • 01Check discrete residual decreases
  • 02Verify max principle for f=0
  • 03Measure wall-clock seconds on one pinned CPU core over at least three seeds.

Evaluation metrics

  • 01discrete L2 error
  • 02iterations to 1e-8 residual
  • 03grid convergence order
  • 04wall-clock seconds on one pinned CPU core

Expected outputs

  • 01solution heatmap
  • 02convergence-by-grid plot

Common failure modes

  • 01Jacobi stalls on fine grids
  • 02red-black ordering breaks naive vectorization
  • 03real data violates the synthetic noise model and the baseline overfits

Stretch goals

  • 01add SOR with optimal omega
  • 02implement conjugate gradient preconditioned by multigrid
  • 03profile the method with cProfile and report the dominant kernel

Research extensions

  • 01derive multigrid convergence factor
  • 02study stencil extensions to anisotropic media

GitHub submission requirements

  • 01A repository whose README states the real-data stress test protocol and the exact command to reproduce it.
  • 02Source for the scratch implementation, a test file, and a results table with uncertainty estimates.
  • 03A two-page report explaining failures on MNIST 70k subset and what the ablation revealed.

Completion rubric

  • 01stencil correct
  • 02three solvers correct
  • 03grid convergence order measured
  • 04Extra credit: profile the method with cProfile and report the dominant kernel

Submit when every rubric item is satisfied and your repository contains runnable code plus a reproduction command.