🧮
🧮 Math & statistics

Pseudoinverse Calculator (Moore–Penrose A⁺ and least-squares solution)

Results update as you type.

Your numbers

Understanding the pseudoinverse calculator — concept and principle

This calculator computes the Moore–Penrose pseudoinverse A⁺ of any matrix, square or rectangular, together with its rank, its type and, if you enter a right-hand side b, the least-squares solution x = A⁺b and its residual. Use it for least-squares fitting, overdetermined or underdetermined systems, linear algebra courses, signal processing and robotics.

Least squares with the pseudoinverseBest line through 3 pointsA[1 1; 1 2; 1 3]b(1, 2, 2)A⁺ = (AᵀA)⁻¹Aᵀ[4/3 1/3 −2/3; −1/2 0 1/2]x = A⁺b(2/3, 1/2)Residual ‖Ax − b‖0.408248line y = 2/3 + t/2 · rank 2
No line passes through all three points; A⁺b gives the one with the smallest squared miss.

How it is calculated

Singular values below a tiny relative tolerance are treated as zero. Simple fractions are shown exactly.

The principle

A rectangular or singular matrix has no ordinary inverse, but the pseudoinverse is the best substitute. It is the unique matrix satisfying the four Penrose conditions: AA⁺A = A, A⁺AA⁺ = A⁺, and both AA⁺ and A⁺A are symmetric. Through the SVD, A stretches along some directions and squashes others to zero; A⁺ undoes the stretching where it can and leaves the squashed directions at zero. As a result, x = A⁺b minimises ‖Ax − b‖, and among all minimisers it has the smallest length.

Worked example

Default: A = [1 1; 1 2; 1 3], b = (1, 2, 2). This fits a line y = c₀ + c₁t through (1, 1), (2, 2), (3, 2).

  1. The columns are independent, so rank = 2 and A⁺ = (AᵀA)⁻¹Aᵀ.
  2. AᵀA = [3 6; 6 14], its inverse = [7/3 −1; −1 1/2].
  3. A⁺ = [4/3 1/3 −2/3; −1/2 0 1/2], a 2 × 3 matrix.
  4. x = A⁺b = (4/3 + 2/3 − 4/3, −1/2 + 0 + 1) = (2/3, 1/2), so the line is y = 2/3 + t/2.
  5. Ax = (7/6, 5/3, 13/6); residual = √((1/6)² + (1/3)² + (1/6)²) ≈ 0.408248.

How to read the result

The rank tells you how much independent information A contains. "Full column rank" means a unique least-squares solution; lower rank means many solutions, and A⁺b picks the shortest one. A residual of 0 means b is exactly reachable; otherwise the residual is the smallest possible miss. For line fitting, x gives the intercept and slope.

Common mistakes

Keep in mind: Results depend on the numerical tolerance for zero singular values. For badly scaled or nearly rank-deficient data, small changes in the input can change the answer a lot.

Frequently asked questions

Is the pseudoinverse the same as the inverse?

Only for square invertible matrices. Otherwise it is a generalisation.

What size is A⁺?

If A is m × n, A⁺ is n × m.

Why use the pseudoinverse for regression?

x = A⁺b gives the ordinary least-squares coefficients, and the SVD route stays stable even when AᵀA is nearly singular.

Sources: Wolfram MathWorld, "Moore-Penrose Matrix Inverse" · J. Demmel, UC Berkeley Math 221 lecture notes, Lecture 3 (Fall 2011)

Checked 9 Nov 2026. Wolfram MathWorld, “Moore-Penrose Matrix Inverse” (the four Penrose conditions, uniqueness, B⁺ = (BᴴB)⁻¹Bᴴ when the inverse exists, z = B⁺c is the shortest least-squares solution); J. Demmel, UC Berkeley Math 221 lecture notes, Lecture 3 (Fall 2011): A⁺ = V·inv(Σ)·Uᵀ for full-rank A. Rank-deficient case via Σ⁺: standard.

🧮 All math & statistics tools →🌍 Calculators by country →