
Forward Automatic Differentiation via Dual Numbers
Alan Edelman and Steven G. Johnson continue MIT's 18.S096 Matrix Calculus for Machine Learning and Beyond with a session on forward-mode automatic differentiation. The core idea is dual numbers, a number system that carries both a value and its derivative through a computation simultaneously. Edelman and Johnson show how arithmetic rules extend naturally to these dual numbers so that running a program on them yields derivatives alongside ordinary outputs, with no symbolic differentiation or finite-difference approximation required. The lecture builds a small automatic differentiation system from scratch in a few lines of Julia, demonstrating how this trick underlies much of the machinery used in machine learning frameworks. The session assumes familiarity with earlier matrix calculus material from the course and is aimed at students who want to understand what is actually happening inside automatic differentiation tools rather than treating them as a black box.