Matrix Calculus (for Machine Learning and Beyond)
Paige Bright, Alan Edelman, Steven G. Johnson
TL;DR
This work introduces matrix calculus as an extension of differential calculus to general vector spaces, framing derivatives as linear operators that map small input changes to first-order output changes. It develops the core toolkit of matrix derivatives, including the differential, gradient, Jacobian, directional derivatives, chain rule, and the differential product rule, with emphasis on computational efficiency through reverse-mode differentiation and automatic differentiation. The notes provide explicit formulas for matrix-valued functions (e.g., $A^{2}$, $A^{3}$, $A^{-1}$) and discuss representations via vectorization and Kronecker products to obtain Jacobians in a standard form. By contrasting forward- and reverse-mode AD and illustrating concrete matrix-function derivatives, the material equips learners with a practical, operator-centric framework for differentiating through large-scale matrix computations and simulations.
Abstract
This course, intended for undergraduates familiar with elementary calculus and linear algebra, introduces the extension of differential calculus to functions on more general vector spaces, such as functions that take as input a matrix and return a matrix inverse or factorization, derivatives of ODE solutions, and even stochastic derivatives of random functions. It emphasizes practical computational applications, such as large-scale optimization and machine learning, where derivatives must be re-imagined in order to be propagated through complicated calculations. The class also discusses efficiency concerns leading to "adjoint" or "reverse-mode" differentiation (a.k.a. "backpropagation"), and gives a gentle introduction to modern automatic differentiation (AD) techniques.
