A symmetric matrix defines a quadratic form, a function whose graph is a bowl, a saddle or a trough. Expand it, symmetrise any square matrix, and use the spectral theorem to remove the cross term so that the eigenvalues read off the shape.
M03.4.1L2 Intermediate25 minIn review (what this means)
The maths and code on this page are checked by automated tests on every change, but an independent reader has not signed it off yet. Spot a mistake or a confusing step? Tell us.
Expand a quadratic form x-transpose S x into a x^2 + 2bxy + c y^2 and write any homogeneous quadratic as a form with a symmetric matrix.
Derive the principal axes theorem: in the coordinates y = Q-transpose x the form becomes a weighted sum of squares, with the eigenvalues as weights.
Classify the shape of a form as a bowl, an upside-down bowl, a saddle or a trough from the signs of its eigenvalues.
Compute a form both directly and in eigen-coordinates, by hand and in NumPy, and check that the two agree.
The question
Near a point where its slope is zero, almost every loss a model is trained on looks like a constant plus a function made only of squares and products of the small steps away from that point, such as \({2x^2 + 2xy + 2y^2}\). Some of these functions are bowls with one lowest point; others are saddles that rise one way and fall another. How can you tell which, from the numbers alone, before you draw anything?
Intuition
Take a symmetric matrix and a point \({(x, y)}\) of the plane, and compute one number from them: the point times the matrix times the point. That number is a height above the point. Do it for every point and you get a surface.
M03.4.1-F1
The running bowl \({2x^2 + 2xy + 2y^2}\) and the running saddle \({x^2 + 4xy + y^2}\). Along the two orange eigenvector directions each surface is a simple parabola, and the eigenvalue sets how steeply it climbs or falls.
The left surface is a bowl: from the origin it goes up whichever way you walk. The right one is a saddle: it goes up along one direction and down along the perpendicular one, like a mountain pass. Both are built from the same ingredients, squares and one cross product \(xy\).
The surprise is in the orange curves. Each surface has two special perpendicular directions. Along them, nothing mixes: the height is just a number times the distance squared. Those directions are the eigenvectors of the matrix, and the numbers are its eigenvalues. So the eigenvalues tell the shape. Two positive eigenvalues make a bowl. One positive and one negative make a saddle.
Build it up
Step 1. Multiply it out. Write the symmetric matrix as \(\mat{S} = \begin{bmatrix} a & b \\ b & c \end{bmatrix}\) and the point as a column \(\vect{x}\). First \({\mat{S}\vect{x}}\), then the dot product with \(\vect{x}\):
The diagonal entries become the squares. The off-diagonal entry \(b\) appears twice, once from each corner, so the cross term is \(2b\,xy\). For the running matrix \(\mat{S} = \begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix}\) this gives \({2x^2 + 2xy + 2y^2}\), and for \(\begin{bmatrix} 1 & 2 \\ 2 & 1 \end{bmatrix}\) it gives \({x^2 + 4xy + y^2}\).
Step 2. Every quadratic is a form. A quadratic form is a function of \(\vect{x}\) in which every term has degree exactly two: squares and products, no single powers and no constant. Read Step 1 backwards to find its matrix. Put the coefficients of the squares on the diagonal and split the coefficient of \(xy\) equally between the two corners. So \({3x^2 - 6xy + 5y^2}\) has the matrix \(\begin{bmatrix} 3 & -3 \\ -3 & 5 \end{bmatrix}\).
What if someone hands you a matrix that is not symmetric, say \(\mat{A} = \begin{bmatrix} 1 & 3 \\ 1 & 1 \end{bmatrix}\)? Its form is \({x^2 + (3 + 1)\,xy + y^2}\), because both corners land on \(xy\). Only the sum of the corners matters, so replace \(\mat{A}\) by the average of itself and its transpose, \(\tfrac12{(\mat{A} + \mat{A}\T)} = \begin{bmatrix} 1 & 2 \\ 2 & 1 \end{bmatrix}\). That is the running saddle. The same holds in any size: a number equals its own transpose, so \({\vect{x}\T\mat{A}\vect{x}} = {\vect{x}\T\mat{A}\T\vect{x}}\), and averaging the two gives \({\vect{x}\T \tfrac12(\mat{A} + \mat{A}\T)\, \vect{x}}\). From now on every form has a symmetric matrix.
Step 3. The cross term is what tilts the picture. Seen from above, the bowl’s contour lines are ellipses (the hiking-map view of M04.10). Without the cross term they would stand upright, with their axes along \(x\) and \(y\). The term \(2xy\) tilts them. To make it vanish we choose new axes along the ellipses’ own axes.
M03.4.1-F2
The bowl’s contour lines in the original coordinates (left) and in eigen-coordinates (right). The ellipses are the same; only the axes we measure along have changed, and with them the cross term has gone.
Step 4. The right axes are the eigenvectors. By the spectral theorem (M03.3.2), a symmetric matrix has perpendicular unit eigenvectors. For the running \(\mat{S}\) they are \({\vect{q}_1 = {(1, 1)/\sqrt2}}\) with \({\lambda_1 = 3}\) and \({\vect{q}_2 = {(1, -1)/\sqrt2}}\) with \({\lambda_2 = 1}\). The new coordinates of a point are its components along them, \({y_1 = \vect{q}_1 \cdot \vect{x}}\) and \({y_2 = \vect{q}_2 \cdot \vect{x}}\). The next section proves that in these coordinates the form is \({3y_1^2 + y_2^2}\).
The formal statement
NoteTheorem: principal axes
Let \(\mat{S}\) be a real symmetric \({n \times n}\) matrix with orthonormal eigenvectors \(\vect{q}_1, \dots, \vect{q}_n\) and eigenvalues \(\lambda_1, \dots, \lambda_n\), so that \({\mat{S} = \mat{Q}\mat{\Lambda}\mat{Q}\T}\). Put \({\vect{y} = \mat{Q}\T\vect{x}}\), that is, \({y_i = \vect{q}_i \cdot \vect{x}}\). Then
\(\mat{\Lambda}\) is diagonal, so \({\mat{\Lambda}\vect{y}}\) has entries \(\lambda_i y_i\), and the dot product with \(\vect{y}\) adds up \(y_i \cdot \lambda_i y_i\). That is the sum of \(\lambda_i y_i^2\). No cross terms survive, because \(\mat{\Lambda}\) has no entries off its diagonal. \(\square\)
Two facts about \(\vect{y}\) make the theorem useful. Since \(\mat{Q}\) is orthogonal (M02.10.2), \({\vect{x} = \mat{Q}\vect{y}}\), so \({\vect{y} = \vect{0}}\) exactly when \({\vect{x} = \vect{0}}\). And lengths are kept: \({\norm{\vect{y}} = \norm{\vect{x}}}\).
The shape from the signs. For a point \({\vect{x} \neq \vect{0}}\) some \(y_i\) is not zero. Read the sum of \(\lambda_i y_i^2\):
all \({\lambda_i > 0}\): every term is at least zero and one is positive, so the form is positive away from the origin. A bowl.
all \({\lambda_i < 0}\): negative away from the origin. An upside-down bowl, a dome.
some positive and some negative: walking along \(\vect{q}_i\) alone gives the height \(\lambda_i y_i^2\), which goes up for a positive \(\lambda_i\) and down for a negative one. A saddle.
all \(\lambda_i \geq 0\) with some equal to zero: along that eigenvector the height stays 0. A trough, a valley with a flat floor. (All \({\lambda_i \leq 0}\) with a zero among them gives the same trough upside down.)
The height on the unit circle. If \({\norm{\vect{x}} = 1}\) then the \(y_i^2\) add up to 1, and the form is a weighted average of the eigenvalues. So it always lies between the smallest and the largest eigenvalue, and reaches each at its eigenvector. This is the Rayleigh quotient of M03.3.4 seen from another side.
M03.4.1-F3
The height along every unit direction. For the bowl it stays between 1 and 3; for the saddle it runs from 3 down to \({-1}\), and the shaded directions are where the saddle goes below zero.
Worked example
The running bowl at \({\vect{x} = (2, 1)}\). Directly,
The worked example as a trace. The eigen-coordinates are the lengths of the two orange shadows of \(\vect{x}\), and both routes give the height 14.
The running saddle. Its matrix has the same eigenvectors, with eigenvalues 3 and \({-1}\), so \({x^2 + 4xy + y^2 = 3y_1^2 - y_2^2}\). At \({(2, 1)}\) both sides give 13: directly \({4 + 8 + 1}\), and in eigen-coordinates \({\tfrac{27}{2} - \tfrac12}\). At \({(1, -1)}\), which lies along \(\vect{q}_2\), the direct value is \({1 - 4 + 1 = -2}\). In eigen-coordinates \({y_1 = 0}\) and \({y_2 = \sqrt2}\), so the form is \({-(\sqrt2)^2 = -2}\). The saddle really does go below zero, exactly in the direction of its negative eigenvalue.
Code
From scratch: a form evaluated straight from the matrix, the symmetrising step, and the shape read from the eigenvalues.
import numpy as npdef form(M, x):"""x-transpose M x, written out as a double sum over the entries.""" n =len(x)returnsum(M[i][j] * x[i] * x[j] for i inrange(n) for j inrange(n))S = np.array([[2.0, 1.0], [1.0, 2.0]]) # the running bowlsaddle = np.array([[1.0, 2.0], [2.0, 1.0]]) # the running saddleA = np.array([[1.0, 3.0], [1.0, 1.0]]) # not symmetricA_sym = (A + A.T) /2x = np.array([2.0, 1.0])print("bowl at (2, 1):", form(S, x), " saddle at (2, 1):", form(saddle, x))print("symmetrised A:\n", A_sym)rng = np.random.default_rng(0)points = rng.normal(size=(1000, 2))same =all(np.isclose(form(A, p), form(A_sym, p)) for p in points)print("A and its symmetric part give the same form on 1000 points:", same)
bowl at (2, 1): 14.0 saddle at (2, 1): 13.0
symmetrised A:
[[1. 2.]
[2. 1.]]
A and its symmetric part give the same form on 1000 points: True
Now the principal axes. numpy.linalg.eigh is made for symmetric matrices: it returns the eigenvalues in ascending order and orthonormal eigenvectors as columns. Their signs are not fixed, but a sign does not change \(y_i^2\).
lam, Q = np.linalg.eigh(S)y = Q.T @ xprint("eigenvalues:", lam)print("y = Q^T x:", y.round(4), " sum of lambda y^2:", round(float(lam @ y**2), 10))def shape(M, tol=1e-12): lam = np.linalg.eigvalsh(M)if np.all(lam > tol):return"bowl"if np.all(lam <-tol):return"dome"if lam.min() <-tol and lam.max() > tol:return"saddle"return"trough or flat"for name, M in [("S", S), ("saddle", saddle), ("[[1,2],[2,4]]", np.array([[1.0, 2.0], [2.0, 4.0]])), ("-S", -S)]:print(f"{name:>14}: eigenvalues {np.linalg.eigvalsh(M)}, shape {shape(M)}")# The height on the unit circle stays between the extreme eigenvalues.theta = np.radians(np.arange(360))circle = np.stack([np.cos(theta), np.sin(theta)], axis=1)heights = np.array([form(saddle, p) for p in circle])print("saddle on the unit circle: min", heights.min().round(6), " max", heights.max().round(6))
eigenvalues: [1. 3.]
y = Q^T x: [-0.7071 2.1213] sum of lambda y^2: 14.0
S: eigenvalues [1. 3.], shape bowl
saddle: eigenvalues [-1. 3.], shape saddle
[[1,2],[2,4]]: eigenvalues [0. 5.], shape trough or flat
-S: eigenvalues [-3. -1.], shape dome
saddle on the unit circle: min -1.0 max 3.0
The sweep over 360 directions finds the extremes \({-1}\) and 3, the two eigenvalues, at 135 and 45 degrees (and again half a turn later, since \(\vect{x}\) and \({-\vect{x}}\) give the same height). In machine learning this is how one reads the shape of a loss near a point: the matrix of second derivatives is a symmetric matrix, and the signs of its eigenvalues say whether the point is the bottom of a bowl or a saddle that training can slide off.
Explore
This module’s interactive, bowl or saddle, lives in lesson M03.4.2. Set \(a\), \(b\) and \(c\) with three sliders and watch the contour lines change from ellipses to parallel lines to hyperbolas as an eigenvalue crosses zero, with the two eigen-axes drawn on the map.
Pitfalls
M03.4.1-F5
Wrong beside right. Positive diagonal entries suggest a bowl (left), but the cross term \(4xy\) wins along the direction \({(1, -1)}\), and the form is a saddle (right).
“Both diagonal entries are positive, so the form is a bowl.”
The diagonal only tells you the height along the two axes: \({f(1, 0) = a}\) and \({f(0, 1) = c}\). The running saddle has \({a = c = 1}\), yet \({f(1, -1) = -2}\). A large cross term can win along a diagonal direction. The eigenvalues, not the diagonal, decide the shape.
“The off-diagonal entry is the coefficient of \(xy\).”
It is half of it. The matrix of \({2x^2 + 2xy + 2y^2}\) has \({b = 1}\), not 2, because \(b\) appears in both corners. Putting the whole coefficient in each corner doubles the cross term and changes the shape: \(\begin{bmatrix} 2 & 2 \\ 2 & 2 \end{bmatrix}\) gives \({2x^2 + 4xy + 2y^2} = {2{(x + y)}^2}\), a trough instead of the bowl.
“A non-symmetric matrix has a different form from its symmetric part.”
It has the same form, because only \({a_{12} + a_{21}}\) reaches the \(xy\) term. But its eigenvalues can be quite different, so read the shape from the eigenvalues of \({\tfrac12{(\mat{A} + \mat{A}\T)}}\). The matrix \({\begin{bmatrix} 1 & 3 \\ 1 & 1 \end{bmatrix}}\) has eigenvalues \(1 \pm \sqrt3\), about 2.73 and \({-0.73}\), while its symmetric part has 3 and \({-1}\).
Check yourself
Recall
1. What does \({\vect{x}\T\mat{S}\vect{x}}\) become for \(\mat{S} = \begin{bmatrix} a & b \\ b & c \end{bmatrix}\)?
Show answer
\({ax^2 + 2bxy + cy^2}\). The entry \(b\) appears in both corners, so the cross term is \(2bxy\).
2. How do you find the symmetric matrix of the form of a non-symmetric matrix \(\mat{A}\)?
Show answer
Take \({\tfrac12{(\mat{A} + \mat{A}\T)}}\). It gives the same form, because \({\vect{x}\T\mat{A}\vect{x}}\) is a number and equals its own transpose.
3. State the principal axes theorem in one line.
Show answer
With \({\vect{y} = \mat{Q}\T\vect{x}}\), where the columns of \(\mat{Q}\) are orthonormal eigenvectors, the form is \({\lambda_1 y_1^2 + \cdots + \lambda_n y_n^2}\), with no cross terms.
4. Which signs of the eigenvalues give a bowl, a saddle and a trough?
Show answer
All positive: a bowl. Some positive and some negative: a saddle. All at least zero, with a zero among them: a trough.
5. Between which two numbers does \({\vect{x}\T\mat{S}\vect{x}}\) lie when \({\norm{\vect{x}} = 1}\)?
Show answer
Between the smallest and the largest eigenvalue of \(\mat{S}\), because it is a weighted average of the eigenvalues with weights \(y_i^2\) that add up to 1.
Exercises
1.★ Write the symmetric matrix of \({5x^2 - 4xy + 2y^2}\), and evaluate the form at \({(1, 2)}\) both directly and as \({\vect{x}\T\mat{S}\vect{x}}\).
Show solution
The squares give the diagonal 5 and 2, and \({-4}\) is split between the corners: \(\mat{S} = \begin{bmatrix} 5 & -2 \\ -2 & 2 \end{bmatrix}\). Directly, \({5 - 8 + 8 = 5}\). As a product, \(\mat{S}\vect{x} = {(5 - 4,\; -2 + 4)} = {(1, 2)}\), and its dot product with \({(1, 2)}\) is \({1 + 4 = 5}\).
2.★★ For the matrix of Exercise 1, find the eigenvalues, write the form as a sum of squares in eigen-coordinates and name its shape.
Show solution
The trace is 7 and the determinant \({10 - 4 = 6}\), so the eigenvalues solve \({\lambda^2 - 7\lambda + 6 = 0}\): \({\lambda = 6}\) and \({\lambda = 1}\). For \({\lambda = 6}\), \({\mat{S} - 6\mat{I}}\) has first row \({(-1, -2)}\), so \({\vect{q}_1 = {(2, -1)/\sqrt5}}\); for \({\lambda = 1}\), the first row is \({(4, -2)}\), so \({\vect{q}_2 = {(1, 2)/\sqrt5}}\). The form is \({6y_1^2 + y_2^2}\) with \({y_1 = {(2x - y)/\sqrt5}}\) and \({y_2 = {(x + 2y)/\sqrt5}}\). Both eigenvalues are positive: a bowl. Check at \({(1, 2)}\): \({y_1 = 0}\) and \({y_2 = \sqrt5}\), so the form is \({0 + 5 = 5}\), as in Exercise 1.
3.★★★ For which values of \(b\) is \({x^2 + 2bxy + y^2}\) a bowl, a trough or a saddle? Find the eigenvalues of its matrix in terms of \(b\).
Show solution
The matrix is \(\begin{bmatrix} 1 & b \\ b & 1 \end{bmatrix}\). Applied to \({(1, 1)}\) it gives \({(1 + b)(1, 1)}\), and applied to \({(1, -1)}\) it gives \({(1 - b)(1, -1)}\), so the eigenvalues are \({1 + b}\) and \({1 - b}\). Both are positive when \({-1 < b < 1}\): a bowl. When \({b = 1}\) or \({b = -1}\) one eigenvalue is zero and the other is 2: a trough, \({(x + y)^2}\) or \({(x - y)^2}\). When \({\abs{b} > 1}\) one eigenvalue is negative and the other positive: a saddle. The running saddle is \({b = 2}\), with eigenvalues 3 and \({-1}\).
Summary card
In eigen-coordinates a quadratic form is a sum of squares weighted by the eigenvalues.
M03.4.1-F1
Bowl: eigenvalues 3 and 1. Saddle: 3 and \({-1}\).
Form.\(\vect{x}\T\mat{S}\vect{x} = ax^2 + 2bxy + cy^2\), with \(\mat{S}\) symmetric.
Symmetrise.\(\mat{A}\) and \({\tfrac12{(\mat{A} + \mat{A}\T)}}\) give the same form.
Principal axes.\({\vect{y} = \mat{Q}\T\vect{x}}\) gives \(\sum \lambda_i y_i^2\).
Shape. All \({\lambda_i > 0}\): bowl. Mixed signs: saddle. A zero among non-negatives: trough.
Unit circle. The form lies between \(\lambda_{\min}\) and \(\lambda_{\max}\).
Sources and next steps
Sources. Each was opened and checked against this lesson on 15 November 2026.
Gilbert Strang, Positive definite matrices and minima, MIT OpenCourseWare 18.06SC, lecture summary. It multiplies out \({\vect{x}\T\mat{A}\vect{x}}\) to \({ax_1^2 + 2bx_1x_2 + cx_2^2}\), shows the saddle of \({2x^2 + 12xy + 7y^2}\), and says that with \({\mat{A} = \mat{Q}\mat{\Lambda}\mat{Q}\T}\) “the eigenvectors of A tell us the directions of the principal axes”.
David Austin, Understanding Linear Algebra, chapter 7, section “Quadratic forms”. It defines the quadratic form of a symmetric matrix and states the Principal Axes Theorem: after the orthogonal change of coordinates \({\vect{y} = \mat{Q}\T\vect{x}}\) the form is \(\sum \lambda_i y_i^2\), with no cross terms.
Marc Peter Deisenroth, A. Aldo Faisal and Cheng Soon Ong, Mathematics for Machine Learning, Section 3.2.3. Its Example 3.4 writes \({9x_1^2 + 12x_1x_2 + 5x_2^2}\) as \({(3x_1 + 2x_2)^2 + x_2^2}\) and shows a symmetric matrix whose form goes negative.
NumPy reference, numpy.linalg.eigh: eigenvalues in ascending order and orthonormal eigenvectors in the columns.