Member-only story

My DS Friend Explained LU, Cholesky, QR, and SVD — Like Refactoring Code

LORY
4 min readApr 18, 2025

To make sure every developer understands

Me: “I’ve been learning matrix decompositions — LU, Cholesky, QR, SVD — and honestly? My head hurts. I kind of understand how they work, but not why or when to use each. Can you break it down in a way for a developer to understand easily?”

DS Friend: “Of course. Think of each decomposition as a different style of refactoring. Depending on the shape of your codebase — and what you’re trying to clean up — you’d reach for a different one.”

LU Decomposition: Incremental Refactoring with Version Control

DS Friend: “Let’s start with LU decomposition. You’ve got a square matrix A as follows:

A = [2 3]
[4 7]

LU splits this into:

L = [1   0]
[2 1]
U = [2 3]
[0 1]

So, A = LU.

Me: “Wait, why exactly would I want to break it down like that?”

DS Friend: “Think about refactoring a messy legacy codebase. The one with HTML, JavaScript, database queries, and business logic all tangled in a single 2000-line file. How did you tackle it?”

Me: “Step by step — extracted the database layer first, then separated business logic, then — .”

DS Friend: “Exactly. In LU decomposition, U is your target: clean, organized code. L tracks how you

--

--

LORY
LORY

Written by LORY

A channel which focusing on developer growth and self improvement

Responses (1)