9  Quadratic From

A quadratic form is a type of polynomial expression that is a sum of terms where each term is either a variable squared or the product of two variables, often associated with a symmetric matrix. Quadratic forms are useful in various areas of mathematics, physics, statistics, and optimization.

9.1 Definition of Quadratic Form

A quadratic form is a type of mathematical expression that can be written as a sum of terms, each of which involves the product of a variable with itself (squared terms) or with another variable (cross terms). In general, a quadratic form is a homogeneous polynomial of degree 2 in a set of variables.

9.1.1 2D Quadratic Form

Let the vector and symmetric matrix in 2D be defined as follows:

x=[x1x2],Q=[q11q12q12q22].

The quadratic form is expressed as:

Q(x)=xTQx.

Expanding this expression gives:

Q(x)=[x1x2][q11q12q12q22][x1x2].

The resulting quadratic form is:

Q(x1,x2)=q11x12+q22x22+2q12x1x2.

9.1.2 3D Quadratic Form

For 3D, the vector and symmetric matrix are defined as follows:

x=[x1x2x3],Q=[q11q12q13q12q22q23q13q23q33].

The quadratic form in this case is expressed as:

Q(x)=xTQx.

Expanding it gives:

Q(x)=[x1x2x3][q11q12q13q12q22q23q13q23q33][x1x2x3].

The expanded quadratic form is:

Q(x1,x2,x3)=q11x12+q22x22+q33x32+2q12x1x2+2q13x1x3+2q23x2x3.

9.1.3 nD Quadratic Form

In n-dimensions, the vector and symmetric matrix are defined as:

x=[x1x2xn],Q=[q11q12q1nq12q22q2nq1nq2nqnn].

The quadratic form is expressed as:

Q(x)=xTQx.

Steps to Calculate a Quadratic Form:

  1. Compute the transpose of x:
    First, express x as a column vector of variables: x=[x1x2xn].
    The transpose of x, denoted as xT, is: xT=[x1x2xn].

  2. Multiply xT with the matrix Q:
    Multiply the row vector xT by the symmetric matrix Q: xTQ=[x1x2xn][q11q12q1nq12q22q2nq1nq2nqnn].
    This produces a row vector: [j=1nq1jxj,j=1nq2jxj,,j=1nqnjxj].

  3. Multiply the result by x:
    Multiply the resulting row vector by the column vector x:

    Q(x)=[j=1nq1jxj,j=1nq2jxj,,j=1nqnjxj][x1x2xn].
    This produces the final quadratic form expression.

  4. Final Expression:

    In summation form: Q(x)=i=1nj=1nqijxixj.

    Separating diagonal and off-diagonal terms: Q(x)=i=1nqiixi2+2i=1nj=i+1nqijxixj.

    Or, in fully expanded form: Q(x)=q11x12+q22x22++qnnxn2+2(q12x1x2+q13x1x3++qn1,nxn1xn).

Key Insights:

  • The diagonal terms qii correspond to the squared variables xi2.
  • The off-diagonal terms qij (where ij) represent the cross terms xixj.

9.2 Key Concepts

  1. Symmetry of the Matrix Q:
    The matrix Q must be symmetric, meaning that qij=qji. This symmetry ensures that the quadratic form only contains real coefficients and simplifies the expression of the form.

  2. Diagonal and Off-Diagonal Terms:
    The quadratic form contains two types of terms:

    • Diagonal terms (qii), which represent the squared terms of the variables xi2.
    • Off-diagonal terms (qij, for ij), which correspond to the interactions between different variables xi and xj (cross terms like xixj).
  3. Scalar Output:
    The result of applying the quadratic form to the vector x is a scalar, i.e., a single numerical value.

9.3 Geometric Interpretation of Quadratic Forms

In the context of quadratic forms, the matrix Q defines the geometric properties of the surface associated with the quadratic form f(x)=xTQx. The geometry of the surface described depends on the properties of Q.

9.3.1 Ellipsoid

If Q is a positive definite matrix, all the eigenvalues of Q are positive. This means that the quadratic form represents a surface where all directions curve outward, such as an ellipsoid in 3D or an ellipse in 2D. In this case, the quadratic form is always positive for any non-zero vector x, indicating a closed surface. An ellipsoid can be described with the equation:

x2a2+y2b2+z2c2=1

00.20.40.60.814D Ellipsoid Representing Positive Definite Matrix

9.3.2 Hyperboloid

If Q is indefinite, meaning that Q has both positive and negative eigenvalues, the quadratic form describes a hyperboloid. In this case, the surface could take on one of two general forms:

  • A one-sheeted hyperboloid, if there’s a pair of positive and negative eigenvalues.A one-sheeted hyperboloid can be described with the equation:

x2a2y2b2z2c2=1 - A two-sheeted hyperboloid, if there’s more complex mixing of positive and negative eigenvalues. A two-sheeted hyperboloid can be described with the equation:

x2a2y2b2z2c2=1

A hyperboloid is an open surface, unlike the ellipsoid. Let consider the following one-sheeted hyperboloid visualization:

00.20.40.60.81One-Sheeted Hyperboloid Representing Indefinite Matrix

9.3.3 Paraboloid

A paraboloid arises when the quadratic form has a special structure, often reflecting a situation where the matrix Q has both positive and zero eigenvalues. This typically occurs when there is a critical point along one of the axes. A paraboloid can open upwards, downwards, or sideways, depending on the sign of the nonzero eigenvalue.

  • An elliptic paraboloid can be described with the equation:

x2a2+y2b2=z

This involves using a positive definite matrix for the elliptic paraboloid.

  • A hyperbolic paraboloid can be described with the equation:

x2a2y2b2=z

The type of surface described by a quadratic form is determined by the positive, negative, or zero nature of the eigenvalues of the matrix Q, which governs the curvature and openness of the graph.

9.4 Applications of Quadratic Forms

Quadratic forms are essential in various disciplines:

  • Optimization: In finding the minimum or maximum of a function, especially quadratic functions in constrained optimization problems.
  • Statistics: In the context of variance-covariance matrices and regression analysis.
  • Physics and Engineering: For representing the energy of a system or describing various physical systems.
  • Machine Learning: In algorithms like Support Vector Machines (SVM) and in kernel methods where the quadratic form is used to map data into higher-dimensional spaces.

9.5 Simple Implementation in Python

Below is a Python implementation of a quadratic form:

import numpy as np

# Define values for x1 and x2
x1, x2 = 1, 2  # Example 

# Matrix Q and vector x
Q = np.array([[2, 2],
              [2, 3]])
x = np.array([[x1], [x2]])

# Compute the quadratic form
Q_x = np.dot(x.T, np.dot(Q, x))
print("Quadratic Form Q(x):", Q_x)
Quadratic Form Q(x): [[22]]