Tivadar Danka Profile picture
Jun 21 19 tweets 6 min read Read on X
Matrix factorizations are the pinnacle results of linear algebra.

From theory to applications, they are behind many theorems, algorithms, and methods. However, it is easy to get lost in the vast jungle of decompositions.

This is how to make sense of them. Image
We are going to study three matrix factorizations:

1. the LU decomposition,
2. the QR decomposition,
3. and the Singular Value Decomposition (SVD).

First, we'll take a look at LU.
1. The LU decomposition.

Let's start at the very beginning: linear equation systems.

Linear equations are surprisingly effective in modeling real-life phenomena: economic processes, biochemical systems, etc. Image
To simplify the notation, we can represent linear equations in a matrix form.

𝐴 holds the coefficients, 𝑥 holds the solution.

How can we solve this? Image
By multiplying the equations with scalars and subtracting them from each other, we can (usually) transform the system into an upper triangular form.

This is called Gaussian elimination.

The resulting system is easy to solve: solve the last equation, then move up progressively. Image
As it turns out, Gaussian elimination is equivalent to multiplying 𝐴 by a lower diagonal matrix.

This gives the famous LU decomposition, factoring 𝐴 into the product of a lower and an upper diagonal matrix. Image
Thus, LU is the same as solving a linear equation.

The LU decomposition can be performed whenever Gaussian elimination can, and it is vital in many applications, for instance, computing determinants or inverting matrices.
2. The QR decomposition.

There are more than one ways to think about matrices. Previously, we viewed them as linear equations, but we can think about them as a horizontal stack of column vectors. Image
We can put these column vectors into the Gram-Schmidt orthogonalization process, yielding a set of orthonormal vectors that span the same space. Image
Just like Gaussian elimination, the Gram-Schmidt process can also be "vectorized", allowing us to use the resulting orthonormal system to factorize 𝐴 into the product of an orthogonal and an upper diagonal matrix.

Voila! This is the gist of QR decomposition. Image
Again, there are tons of applications, but the most significant one is the famous QR algorithm, using the QR decomposition to find the eigenvalues and the eigenvectors of arbitrary matrices.

en.wikipedia.org/wiki/QR_algori…
3. The Singular Value Decomposition.

SVD is undoubtedly one of the pinnacle results of linear algebra, omnipresent in computer science and machine learning. For instance, the famous PCA algorithm is a version of SVD.
To understand the SVD, we should view matrices as linear transformations.

In essence, a linear transformation is a distortion of the underlying vector space, as illustrated below. Image
Although linear transformations can be complex, they are built from a few basic building blocks: rotations, reflections, stretchings.

A combination of rotations + reflections corresponds to a matrix whose columns are orthogonal.

Stretchings correspond to diagonal matrices.
On the level of transformations, SVD says that every transformation is a composition of

1. a rotations + reflections combo,
2. a stretching,
3. and a final rotations + reflections combo,

in that order. Image
Translating it to the language of matrices, we obtain the factorization of 𝐴 into orthogonal and diagonal matrices.

This is an extremely strong result. Like the prime factorization theorem of integers, just for matrices.

(SVD works for non-square matrices as well.) Image
SVD is everywhere in linear algebra. For instance, we can

1. generalize the notion of the inverse matrix to non-square matrices,
2. reduce the dimensionality of data,
3. approximate matrices with low-rank ones,

and many more.
You can dive deeper on my weekly newsletter.

Join here: thepalindrome.org
This is just the tip of the iceberg. If you are in more about the beauties of linear algebra, check out my Mathematics of Machine Learning book!

Understanding mathematics will make you a better engineer, and I want to help you with that.

amazon.com/Mathematics-Ma…

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Tivadar Danka

Tivadar Danka Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @TivadarDanka

Jun 23
Understanding graph theory will seriously enhance your engineering skills; you must absolutely be familiar with them.

Here's a graph theory quickstart, in collaboration with @alepiad.

Read on: Image
What do the internet, your brain, the entire list of people you’ve ever met, and the city you live in have in common?

These are all radically different concepts, but they share a common trait.

They are all networks that establish relationships between objects. Image
As distinct as these things seem to be, they share common properties.

For example, the meaning of “distance” is different for

• Social networks
• Physical networks
• Information networks

But in all cases, there is a sense in which some objects are “close” or “far”. Image
Read 15 tweets
Jun 22
In machine learning, we take gradient descent for granted.

We rarely question why it works.

What's usually told is the mountain-climbing analogue: to find the valley, step towards the steepest descent.

But why does this work so well? Read on. Image
Our journey is leading through

• differentiation, as the rate of change,
• the basics of differential equations,
• and equilibrium states.

Buckle up! Deep dive into the beautiful world of dynamical systems incoming. (Full post link at the end.)
First, let's talk about derivatives and their mechanical interpretation!

Suppose that the position of an object at time t is given by the function x(t), and for simplicity, assume that it is moving along a straight line — as the distance-time plot illustrates below. Image
Read 27 tweets
Jun 20
Matrix multiplication is not easy to understand.

Even looking at the definition used to make me sweat, let alone trying to comprehend the pattern. Yet, there is a stunningly simple explanation behind it.

Let's pull back the curtain! Image
First, the raw definition.

This is how the product of A and B is given. Not the easiest (or most pleasant) to look at.

We are going to unwrap this. Image
Here is a quick visualization before the technical details.

The element in the i-th row and j-th column of AB is the dot product of A's i-th row and B's j-th column. Image
Read 17 tweets
Jun 19
The single most undervalued fact of linear algebra: matrices are graphs, and graphs are matrices.

Encoding matrices as graphs is a cheat code, making complex behavior simple to study.

Let me show you how! Image
If you looked at the example above, you probably figured out the rule.

Each row is a node, and each element represents a directed and weighted edge. Edges of zero elements are omitted.

The element in the 𝑖-th row and 𝑗-th column corresponds to an edge going from 𝑖 to 𝑗.
To unwrap the definition a bit, let's check the first row, which corresponds to the edges outgoing from the first node. Image
Read 18 tweets
Jun 17
Behold one of the mightiest tools in mathematics: the camel principle.

I am dead serious. Deep down, this tiny rule is the cog in many methods. Ones that you use every day.

Here is what it is, how it works, and why it is essential. Image
First, the story.

The old Arab passes away, leaving half of his fortune to his eldest son, third to his middle son, and ninth to his smallest.

Upon opening the stable, they realize that the old man had 17 camels. Image
This is a problem, as they cannot split 17 camels into 1/2, 1/3, and 1/9 without cutting some in half.

So, they turn to the wise neighbor for advice. Image
Read 19 tweets
Jun 14
The single biggest argument about statistics: is probability frequentist or Bayesian?

It's neither, and I'll explain why.

Buckle up. Deep-dive explanation incoming. Image
First, let's look at what is probability.

Probability quantitatively measures the likelihood of events, like rolling six with a dice. It's a number between zero and one. This is independent of interpretation; it’s a rule set in stone. Image
In the language of probability theory, the events are formalized by sets within an event space.

The event space is also a set, usually denoted by Ω.) Image
Read 34 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(