Computational Optimization for AI
Written for Rice University's sophomore course COMP 282, this book connects vectors, matrices, and multivariable calculus to the algorithms that train modern AI models. Across six chapters, it pairs geometric intuition with exact floating-point operation counts and Big-O scaling: from inner products, norms, and least squares to gradient descent, automatic differentiation, eigendecomposition, the power method, Newton's method, and convexity.
What the web edition lets you do
Drag vectors and step through the sum
Move x and y in the plane with mouse, touch, or arrow keys while formulas update live, or step term by term through p-dimensional inner products and count all 2p - 1 flops.
Step through Python without boilerplate
Read only the core mathematical loop. Step through each line to watch i, result, and the flop count change, or expand show setup to inspect the inputs.
1def inner_product_loop(x, y):
2 result = x[0] * y[0]
3 for i in range(1, len(x)):
4 result += x[i] * y[i]
5 return result
6
7print(inner_product_loop(x, y))
Read longer code in full-width sessions
When code is too long for the margin, the reading pauses for a code session: the code, its recorded output and a chart, side by side.
Chapters
-
CH 01 · p. 1
Vectors, Norms, and the Cost of Doing AI
This chapter builds upon our foundational understanding of vector spaces to introduce the tools necessary for measuring complexity, evaluating data and comparing algorithms operating on vectors.
-
CH 02 · p. 34
Optimization: from problems to gradient descent
We introduce the paradigm of optimization by framing real-world tasks as problems of finding the "best" vector.
-
CH 03 · p. 75
Matrices: operations, norms, and geometry
This chapter moves from one-dimensional vectors to two-dimensional matrices, the fundamental structures for representing datasets, transformations, and the very architecture of neural networks.
-
CH 04 · p. 117
Matrix inverse and eigendecomposition
This chapter introduces two of the most powerful concepts in advanced linear algebra: the matrix inverse and the eigendecomposition.
-
CH 05 · p. 150
The power method
This chapter extends the eigendecomposition story of Chapter 4 to arbitrary matrices via the Singular Value Decomposition, then explores the relationship between both decompositions and optimization.
-
CH 06 · p. 192
Curvature, Newton's method, and convexity
We now reverse our perspective and employ eigendecomposition as a powerful analytical tool to dissect the geometry of optimization problems.
License
Text: CC BY-NC-SA 4.0. Code: MIT.
How to cite
Anastasios Kyrillidis, Computational Optimization for AI (COMP 282 Lecture Notes), Rice University, 2026.