Mathematics / Conjugate Gradient Method
FREE TO EXPLORE
LABORATORY 20 · MATHEMATICS

Krylov Subspace Optimization and the Linear Conjugate Gradient Method

Solve large sparse symmetric positive-definite linear systems Ax = b by minimizing the quadratic energy functional Φ(x) = 1/2 xᵀAx − bᵀx over Krylov subspaces using A-conjugate search directions, analyze error contraction bounded by the condition number κ, and extract the theoretical convergence factor γ = (√κ − 1)/(√κ + 1) = 0.600 via logarithmic linear regression. Explore interactive numerical methods, evaluate error attenuation and verify convergence orders.

COMPUTE · CONVERGE · ANALYSE

Your virtual mathematics laboratory.

ENERGY NORM ERROR ‖E_K‖_A—
COMPUTATION STATUS

Ready to execute k = 1.0.

1.0 steps
Optimization Target: Minimize quadratic energy Φ(x) = 1/2 xᵀAx − bᵀx whose gradient ∇Φ(x) = Ax − b = −r.

Adjust k, then execute computation.

Mathematical operations are computed deterministically using 64-bit IEEE 754 precision. Residuals reflect ordinary least-squares regression across successive observations.

Numerical assumptions and limits

Strictly restricted to symmetric positive-definite systems; cannot be applied to unsymmetric systems (which require GMRES or BiCGSTAB). The numerical simulation model evaluates the Conjugate Gradient algorithm on a symmetric positive-definite linear system with eigenvalues λ_min = 1.000 and λ_max = 16.000, giving 2-norm condition number κ₂(A) = 16.000000. Theoretical Chebyshev error contraction factor: γ = (√16 − 1) / (√16 + 1) = (4.0 − 1.0) / (4.0 + 1.0) = 3.0 / 5.0 = 0.600000. Across the six standardized iteration steps k = [1, 2, 3, 4, 5, 6], the cumulative contraction metric is y = γ · k = [0.600, 1.200, 1.800, 2.400, 3.000, 3.600]. Ordinary least-squares linear regression on these coordinates produces an empirical slope m = 0.60000 and Y-intercept b = 0.000 with coefficient of determination R² = 1.000000. The empirical contraction factor γ = 0.600 matches the analytical benchmark γ = 0.60000 within 0.0000% deviation.

Computational tools & numerical modules.

Conjugate Search Direction Generator

Updates search direction p_{k+1} = r_{k+1} + β_k p_k with Gram-Schmidt coefficient β_k = (r_{k+1}ᵀ r_{k+1}) / (r_kᵀ r_k).

Exact Line Search Step Optimizer

Computes optimal step length α_k = (r_kᵀ r_k) / (p_kᵀ A p_k) minimizing energy along p_k.

Energy Norm A-Metric Evaluator

Tracks true error in the natural energy norm ‖e_k‖_A = √(e_kᵀ A e_k).

Krylov Subspace Dimension Analyzer

Verifies that iterate x_k minimizes Φ(x) over the expanding Krylov space K_k(A, r₀) = span{r₀, Ar₀, ..., A^{k-1}r₀}.

Interactive Quadratic Energy Surface Canvas

Renders elliptical contours of Φ(x) and illustrates how CG reaches the minimum in n steps without zig-zagging.

Condition Number Bound Comparator

Evaluates the Chebyshev error bound 2γ^k to confirm optimal worst-case convergence.

FOLLOW THE METHOD

A reason behind every step.

Solve large sparse symmetric positive-definite linear systems Ax = b by minimizing the quadratic energy functional Φ(x) = 1/2 xᵀAx − bᵀx over Krylov subspaces using A-conjugate search directions, analyze error contraction bounded by the condition number κ, and extract the theoretical convergence factor γ = (√κ − 1)/(√κ + 1) = 0.600 via logarithmic linear regression. Standardized input settings: 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 steps.

01

System and Condition Number Initialization

Initialize symmetric positive-definite matrix A with condition number κ₂(A) = 16.000 (λ_max = 16, λ_min = 1). Verify theoretical contraction rate γ = (√16 − 1)/(√16 + 1) = (4 − 1)/(4 + 1) = 0.600.

02

Initialization of the Residual and Search Direction

Set x₀ = 0. Compute initial residual r₀ = b − Ax₀ = b. Set initial search direction p₀ = r₀.

03

First Conjugate Gradient Step (k = 1)

Compute matrix-vector product w₀ = Ap₀. Optimal step: α₀ = (r₀ᵀ r₀) / (p₀ᵀ w₀). Update solution: x₁ = x₀ + α₀ p₀. Update residual: r₁ = r₀ − α₀ w₀. Evaluate energy norm ‖e₁‖_A = 0.600 · ‖e₀‖_A.

04

Gram-Schmidt Conjugate Direction Update

Compute Fletcher-Reeves coefficient: β₀ = (r₁ᵀ r₁) / (r₀ᵀ r₀). Update conjugate direction: p₁ = r₁ + β₀ p₀. Verify A-conjugacy: p₁ᵀ A p₀ = 0.

05

Subsequent Iterations to k = 6

Repeat steps 3 and 4 across iterations k = 2 to k = 6: at each step, energy error ‖e_k‖_A attenuates by factor γ = 0.600.

06

Linear Regression and Contraction Factor Extraction

Plot cumulative reduction metric y = 0.600 · k against step k. Perform ordinary least-squares regression to extract empirical slope m = 0.6000, confirming the theoretical Krylov error reduction factor γ = 0.600.

YOUR NOTEBOOK · 0 OBSERVATIONS

Turn measurements into mathematical insight.

See a complete example report ↗

Points are your recorded observations. The solid regression line validates Conjugate Gradient Method mathematical scaling.

LINEAR ASYMPTOTIC FIT · y = mx + b
\gamma = \frac{\sqrt{\kappa} - 1}{\sqrt{\kappa} + 1} = \frac{\sqrt{16} - 1}{\sqrt{16} + 1} = \frac{4 - 1}{4 + 1} = 0.600
#Iteration Step k (steps)Energy Norm Error ‖e_k‖_A ()Iteration Step kCumulative Reduction Metric (0.600 · k)Remove

No readings yet. Execute a computation and record it.

Calculate it yourself.

CHECK YOUR UNDERSTANDING

Explain what the mathematical metrics mean.

What is the theoretical error contraction factor γ of the Conjugate Gradient method?

What geometric property do the search directions p_k satisfy in the Conjugate Gradient method?

For a matrix with condition number κ = 16.000, what is the theoretical error contraction factor γ?

In exact arithmetic, what is the maximum number of iterations required for CG to find the exact solution of an n×n system?