Matrix calculus is an elusive topic: too complicated for multivariable calculus, too simple for analysis, too off-topic for linear algebra, and a prerequisite for several machine learning courses. As a teaching assistant for a machine learning course over several semesters, I had the unusual opportunity to coach hundreds of students through their first pass at the subject. One struggle common to nearly all of them was their first encounter with matrix calculus. Even students familiar with multivariable calculus initially struggled to make sense of the notation — and more importantly, of what any of it meant.

Who could blame them? After all, mathematicians, statisticians, and physicists disagree among themselves about which notation to use. In writing this series, I hope to bridge the gap between multivariable calculus and matrix calculus; the latter is, in many ways, just a notational difference from the former.

This series develops the meaning of the derivative of matrix-like structures. We will derive the derivatives of common matrix expressions and build a framework for understanding — and computing — the derivatives of more complex ones.

Matrix calculus is inherently an advanced topic, requiring both linear algebra and multivariable calculus, so treat those two as prerequisites. I will try to provide context wherever possible to keep the guide accessible to readers from all backgrounds.

A note on notation

The most familiar symbols for the derivative, and likely the ones taught in elementary courses, are (Lagrange's notation) and (Leibniz's notation). Both are valid and have their own advantages, but this guide uses Euler's notation, , to denote the derivative of matrix-like objects, or of elements within a matrix-like object. When the derivative is a scalar-like object, we use Leibniz's notation. An example:

Suppose is given by . The derivative of this function, following the well-known power rule, is . Notice that we used Leibniz's notation because the derivative is a scalar value.

Now suppose is given by . The total derivative of this function is

(Don't worry if you're not yet sure what a total derivative is — it's a concept we'll build up throughout this guide!)

Notice how we use Euler's notation here to denote the matrix-like object that is the total derivative of . To refer to either of the objects inside the total derivative, we can write , where the subscript means the derivative with respect to the variable.

When we use differentiation as an operator, we may write or interchangeably depending on the context. If we are propagating the differentiation operator into a matrix-like object, we continue to use Euler's notation.

Finally, this guide is a living document. Typos may arise, or worse, I might have made a genuine mistake! Please email me at alexander.wang2001@gmail.com to point out any errors or mistakes in the articles, and I'll try to correct them as soon as I can. Thank you!

In this series

Back to blog