Linear System Solver (2×2)

Solve coupled linear equations Ax = b from circuit and mechanics models

Parameters

ⓘ
ⓘ
ⓘ
ⓘ
ⓘ
ⓘ
Show Trail

Controls

xⓘ

Calculated Values

x₁:
1.40;1.40;
x₂:
1.20;1.20;
det(A):
5.00;5.00;
Residual |Ax−b|:
0.00;0.00;

Examples

Sample system

[[2,1],[1,3]] x = [4,5].

  • x1: 1.401.40
  • x2: 1.201.20

Visualization

Linear Systems in Physics

Many steady-state physics problems reduce to Ax = b: two-loop Kirchhoff laws, coupled spring equilibria, mixing constraints, and network flows. For 2×2 systems, Cramer’s rule and Gaussian elimination are fast and instructive.

The determinant det(A) = a₁₁a₂₂ − a₁₂a₂₁ measures whether the system has a unique solution. det(A) = 0 means the equations are parallel or redundant — physically, the model is under- or over-constrained.

Gaussian elimination subtracts multiples of one equation from another to reach upper-triangular form, then back-substitutes. This scales to large sparse systems in simulation codes.

Always verify by substituting x back into Ax = b. Residuals |Ax − b| reveal round-off or modeling errors — propagate uncertainties with Error Propagation on measured coefficients.

Eigenvalue problems (Power Method) extend linear algebra to normal modes and stability analysis.

Key Concepts

  • det(A) ≠ 0 → unique solution
  • Cramer: xᵢ = det(Aᵢ)/det(A)
  • Elimination: pivot, eliminate, back-substitute
  • Residual r = b − Ax checks accuracy
  • Ill-conditioned matrices amplify errors

Real-World Applications

  • Two-loop DC circuit currents
  • Static equilibrium of linked bodies
  • Least-squares normal equations (2-parameter fit)
  • Small vibration modes (with eigen tools)

Explore Further

More computational physics tools

  • Gradient Descent

    Iteratively minimize f(x) by following the negative gradient with animated path visualization.

  • 1D Heat Equation

    Finite-difference FTCS solution to the diffusion equation with animated temperature profiles.

  • 1D Wave Equation

    Leapfrog finite-difference solution to the wave equation with animated wave propagation.

  • Numerical Integration

    Trapezoidal and Simpson rules to approximate definite integrals with error vs exact solutions.

  • ODE Solver

    Euler and Runge-Kutta 4 methods for first-order ODEs with comparison to analytic solutions.

  • Monte Carlo Intro

    Estimate π and integrals by random sampling — introduction to stochastic computational physics.

Physics Equations

System:
(a11a12a21a22)(x1x2)=(b1b2)\begin{pmatrix}a_{11}&a_{12}\\a_{21}&a_{22}\end{pmatrix}\begin{pmatrix}x_1\\x_2\end{pmatrix}=\begin{pmatrix}b_1\\b_2\end{pmatrix}
det(A):
det⁡(A)=a11a22−a12a21\det(A)=a_{11}a_{22}-a_{12}a_{21}

Step-by-Step Solution

See how the main results are calculated.

1

Step 1: Write the 2×2 system

Coupled linear equations from circuit loops, force balance, or network models.

Equation:

(2113)(x1x2)=(45)\begin{pmatrix}2 & 1\\1 & 3\end{pmatrix}\begin{pmatrix}x_1\\x_2\end{pmatrix}=\begin{pmatrix}4\\5\end{pmatrix}
2

Step 2: Determinant

Equation:

det⁡(A)=a11a22−a12a21\det(A) = a_{11}a_{22} - a_{12}a_{21}

Calculation:

det⁡(A)=2×3−1×1=5.000000\det(A) = 2\times3 - 1\times1 = 5.000000

Result:

Nonsingular system
3

Step 3: Cramer / elimination solution

Equation:

x1=b1a22−b2a12det⁡(A),x2=a11b2−a21b1det⁡(A)x_1 = \frac{b_1 a_{22} - b_2 a_{12}}{\det(A)},\quad x_2 = \frac{a_{11} b_2 - a_{21} b_1}{\det(A)}

Calculation:

x1=1.400000,x2=1.200000x_1 = 1.400000,\quad x_2 = 1.200000

Result:

Solution: (1.4000, 1.2000)
4

Step 4: Verify A x = b

Calculation:

a11x1+a12x2=4.0000,a21x1+a22x2=5.0000a_{11}x_1+a_{12}x_2 = 4.0000,\quad a_{21}x_1+a_{22}x_2 = 5.0000

Result:

Shouldmatchb1=4,b2=5Should match b₁ = 4, b₂ = 5

Frequently Asked Questions (FAQ)

What if det(A) = 0?

No unique solution — revise the physical model or remove redundancy.

Does this scale to 3×3?

Same elimination idea; use matrix tools for larger n.

Practice MCQs

  1. det(A) = 0 implies:
  2. Gaussian elimination goal:
  3. Residual b − Ax should be:
  4. 2×2 Cramer uses:
  5. Coupled springs at equilibrium give: