If A−1 is known, how do you derive the Sherman–Morrison formula for (A+uu⊤)−1? How do you verify it for A=diag⁡(2,1) and u=(1,2)⊤, and why does it matter for online ridge regression?

Linear algebra and optimisation, Matrix inverses
Level L3 Intermediate. Length Long. Nature Mat Mathematical.

What's being asked

Whether you can derive and apply the rank-one inverse update, and see that it cuts the cost from O(d3) to O(d2).

Key idea

(A+uu⊤)−1=A−1−A−1uu⊤A−11+u⊤A−1u, valid when 1+u⊤A−1u≠0.

Steps

  1. Guess that the inverse has the form A−1−c A−1uu⊤A−1 for a scalar c, because a rank-one change should give a rank-one correction.
  2. Multiply by A+uu⊤: (A+uu⊤)(A−1−cA−1uu⊤A−1)=I+uu⊤A−1−c uu⊤A−1−c u(u⊤A−1u)u⊤A−1.
  3. Collect the uu⊤A−1 terms: [1−c−c (u⊤A−1u)] uu⊤A−1. This is zero when c=11+u⊤A−1u, which gives the formula.
  4. Verify numerically. A−1=diag⁡(12,1) and A−1u=(0.5,2), so u⊤A−1u=0.5+4=4.5 and the denominator is 5.5.
  5. The correction is 15.5(0.25114). So (A+uu⊤)−1=(0.5−0.0455−0.1818−0.18181−0.7273)=111(5−2−23).
  6. Check: A+uu⊤=(3225) has determinant 11, whose inverse is 111(5−2−23). This matches. The determinant lemma gives the same check: det⁡(A+uu⊤)=det⁡A (1+u⊤A−1u)=2×5.5=11.
  7. Use: in online ridge regression, A=X⊤X+λI and each new example adds xx⊤. The formula updates A−1 in O(d2) instead of re-inverting in O(d3). This is the idea behind recursive least squares.

Common mistakes

How long your answer should be

One page; 6 minutes.

Last checked on 4 December 2026.

Read this

Previous in Linear algebra and optimisation: For the underdetermined system Ax=b with A=(110011) and b=(2,2)⊤, how do you find the solution with the smallest ℓ2 norm, and why is the answer x=A⊤(AA⊤)−1b?
Next in Linear algebra and optimisation: Derive why the direction of fastest local decrease of f at x is −∇f(x), using a first-order Taylor expansion and the Cauchy–Schwarz inequality. For f(x,y)=x2+3y2 at (1,1), compare the rate of decrease along −∇f/∥∇f∥ with the one along (0,−1)?