A quadratic form is a scalar built from a vector and a symmetric matrix, written as x^T A x. It describes circles, ellipses, hyperellipsoids, and curvature in matrix form. section 4.2 section 4.0
With symmetric A, the same expression can represent a hypersphere when A is diagonal, or a rotated hyperellipsoid when off-diagonal terms appear. Rotating the coordinate system diagonalizes the shape. section 4.2 section 2.17.1
Key uses here include:
- finding principal axes by diagonalizing A. section 4.2.1
- measuring variance along a direction as l^T C l. section 4.7
- expressing the Hessian term in a multidimensional Taylor expansion. section 4.2
- computing the spectral norm through x̂^T A^T A x̂. section 4.3.1
Ellipse example
The equation 5x^2 + 6xy + 5y^2 = 20 is rewritten as a matrix quadratic form. Diagonalizing the symmetric matrix reveals eigenvectors at 45°, which align with the ellipse axes. section 2.17.1
Listing 2.21 Axes of a hyperellipse
ellipse_eq = sy.Eq(5*x**2 + 5*y**2 +
6*x*y, 20) ①
A = torch.tensor([[5, 3], [3, 5]]).float()
l, S = torch.linalg.eig(A)
x_axis_vec = torch.zeros((A.shape[0])) ②
first_eigen_vec = S[:, 0] ③
dot_prod = torch.dot(x_axis_vec, first_eigen_vec) ④
theta = math.acos(dot_prod)
theta = math.degrees(theta) ⑤ ① Equation of the ellipse: 5x2 + 6xy + 5y2 = 20 or ② X-axis vector ③ Major axis of the ellipse ④ The dot product between two vectors is the cosine of the angle between them. ⑤ The angle between the ellipse’s major axis and the X-axis: 45° (see figure 2.16) |
Shows the ellipse equation, matrix form, eigenvector-based axis direction, and the 45° angle calculation. section 2.17.1
Equation 4.2
| Q = x̂TAx̂ = x̂TSΛSTx̂ = ŷTΛŷ |
Shows the unit-vector form after diagonalization, making the eigenvalue weighting explicit. section 4.2.1
