Tutorials › Linear Algebra › Projection Onto A Nonorthogonal Polynomial Basis

Orthogonal Complements and Projections · Tutorial 670 of 1000

Projection Onto A Nonorthogonal Polynomial Basis

Set up and solve Gram matrix equations to find and verify the closest polynomial in a specified subspace.

Intermediate 12 min read

What You'll Learn

  • Build the Gram matrix and right-hand side from a polynomial inner product
  • Solve for projection coefficients when the basis vectors are not orthogonal
  • Prove that the Gram matrix is invertible for a basis
  • Check a proposed projection by testing residual orthogonality
  • Verify why the resulting polynomial is the unique closest one

Why a Nonorthogonal Basis Needs a System

When a basis is orthogonal, each projection coefficient can be found with a separate inner product. A nonorthogonal basis behaves differently: its basis polynomials interact, so changing one coefficient affects the inner product with several basis elements. The coefficients must be found together by solving a system of equations. The matrix of that system is the Gram matrix, whose entries record the inner products between basis polynomials.

We work over \(\mathbb{R}\). Let \(P_m\) denote the vector space of real polynomials of degree at most \(m\), equipped with a specified inner product \(\langle\cdot,\cdot\rangle\). Let \(S\) be a subspace with ordered basis \((\phi_1,\dots,\phi_k)\), and let \(f\in P_m\). An inner product is positive definite, symmetric, and bilinear; in particular, \(\langle g,g\rangle\geq 0\), with equality only when \(g\) is the zero polynomial.

Definition: The Gram matrix of the ordered basis \((\phi_1,\dots,\phi_k)\) is the \(k\times k\) matrix \(\mathbf{G}\) with entries \(G_{ij}=\langle\phi_i,\phi_j\rangle\). The Gram equations for \(f\) are \(\mathbf{G}\mathbf{c}=\mathbf{b}\), where \(b_i=\langle f,\phi_i\rangle\). If their solution is \(\mathbf{c}=(c_1,\dots,c_k)^\top\), the polynomial \(p=\sum_{j=1}^k c_j\phi_j\) is the projection of \(f\) onto \(S\).

To understand the equations, write the residual as \(r=f-p\). We want it orthogonal to every polynomial in \(S\), and it is enough to require orthogonality to each basis element. By bilinearity and symmetry, the \(i\)-th requirement is

$$ \langle r,\phi_i\rangle=0 \quad\Longleftrightarrow\quad \sum_{j=1}^k c_j\langle\phi_i,\phi_j\rangle =\langle f,\phi_i\rangle. $$

These are precisely the rows of \(\mathbf{G}\mathbf{c}=\mathbf{b}\). The basis need not be orthogonal; the off-diagonal entries of \(\mathbf{G}\) account for its interactions.

Why the Gram Equations Have a Unique Solution

Theorem: Let \(S\) be a finite-dimensional subspace of a real inner product space, let \((\phi_1,\dots,\phi_k)\) be a basis for \(S\), and let \(f\) be any vector in the space. The Gram equations have a unique solution. The polynomial \(p=\sum_{j=1}^k c_j\phi_j\) given by that solution satisfies \(f-p\perp S\) and is the unique element of \(S\) closest to \(f\) in the norm \(\|g\|=\sqrt{\langle g,g\rangle}\).

Proof. First, the Gram matrix is invertible. For any coefficient column \(\mathbf{d}=(d_1,\dots,d_k)^\top\), let \(g=\sum_{i=1}^k d_i\phi_i\). Symmetry and bilinearity give \(\mathbf{d}^{\top}\mathbf{G}\mathbf{d}=\langle g,g\rangle\). If \(\mathbf{d}\ne\mathbf{0}\), at least one coefficient is nonzero, and basis independence implies \(g\ne\mathbf{0}\). Positive definiteness then gives \(\mathbf{d}^{\top}\mathbf{G}\mathbf{d}>0\). In particular, \(\mathbf{G}\mathbf{d}=\mathbf{0}\) is possible only for \(\mathbf{d}=\mathbf{0}\). A square matrix with trivial null space is invertible, so \(\mathbf{G}\mathbf{c}=\mathbf{b}\) has a unique solution.

For this solution, the \(i\)-th Gram equation says \(\langle f,\phi_i\rangle=\sum_j c_j\langle\phi_j,\phi_i\rangle\). Therefore \(\langle f-p,\phi_i\rangle=0\) for each \(i\). Every \(s\in S\) is a linear combination of the \(\phi_i\), so bilinearity gives \(\langle f-p,s\rangle=0\); that is, \(f-p\perp S\).

Finally, take any \(q\in S\). Since \(p\in S\), the difference \(s=q-p\) belongs to \(S\), and \(f-q=(f-p)-s\). The residual \(f-p\) is orthogonal to \(s\), so expanding the squared norm gives \(\|f-q\|^2=\|f-p\|^2+\|s\|^2\). The second term is nonnegative and equals zero only when \(s=\mathbf{0}\), or \(q=p\). Thus \(p\) is the unique closest element of \(S\) to \(f\). \(\square\)

Worked Polynomial Projections

Worked Example: Projection Using an Integral Inner Product

Use the inner product \(\langle g,h\rangle=\int_{-1}^{1}g(x)h(x)\,dx\). Find the closest polynomial to \(f(x)=x^2\) in \(S=\operatorname{span}\{1,1+x\}\). The displayed polynomials are a basis: they are independent, since \(a+b(1+x)=0\) as a polynomial forces \(b=0\) from the coefficient of \(x\), then \(a=0\). They are not orthogonal, because \(\langle 1,1+x\rangle=2\ne0\).

Compute the entries of the Gram matrix and the right-hand side. The odd powers integrate to zero on \([-1,1]\):

$$ \mathbf{G}= \begin{bmatrix} \langle 1,1\rangle&\langle 1,1+x\rangle\\ \langle 1+x,1\rangle&\langle 1+x,1+x\rangle \end{bmatrix} = \begin{bmatrix} 2&2\\ 2&\frac{8}{3} \end{bmatrix}, \qquad \mathbf{b}= \begin{bmatrix} \langle x^2,1\rangle\\ \langle x^2,1+x\rangle \end{bmatrix} = \begin{bmatrix} \frac{2}{3}\\ \frac{2}{3} \end{bmatrix}. $$

Writing \(p(x)=a+b(1+x)\), solve the Gram equations. Subtract the first equation from the second to find \(b\), then use the first equation to find \(a\):

$$ \begin{aligned} 2a+2b&=\frac{2}{3},\\ 2a+\frac{8}{3}b&=\frac{2}{3},\\ \frac{2}{3}b&=0,\qquad b=0,\qquad a=\frac{1}{3}. \end{aligned} $$

Thus \(p(x)=\frac{1}{3}\). Check the equations by substitution: \(2(\frac13)+2(0)=\frac23\), and \(2(\frac13)+\frac83(0)=\frac23\). The residual \(r(x)=x^2-\frac13\) is orthogonal to both basis polynomials:

$$ \langle r,1\rangle=\frac{2}{3}-\frac{1}{3}(2)=0, \qquad \langle r,1+x\rangle =\frac{2}{3}-\frac{1}{3}(2)=0. $$

The theorem shows that this is the unique closest polynomial in \(S\). As an additional check, its squared error is \(\int_{-1}^1(x^2-\frac13)^2\,dx=\frac25-\frac49+\frac29=\frac{8}{45}\).

Worked Example: A Coefficient Inner Product

On \(P_2\), define the inner product by taking the dot product of coefficient lists: if \(g(x)=a_0+a_1x+a_2x^2\) and \(h(x)=b_0+b_1x+b_2x^2\), set \(\langle g,h\rangle=a_0b_0+a_1b_1+a_2b_2\). Project \(f(x)=2+x+x^2\) onto \(S=\operatorname{span}\{1,1+x\}\). This is an inner product because it is the usual dot product on the three coefficients. The basis is nonorthogonal: \(\langle 1,1+x\rangle=1\).

The Gram entries are \(\langle1,1\rangle=1\), \(\langle1,1+x\rangle=1\), and \(\langle1+x,1+x\rangle=2\). The right-hand entries are \(\langle f,1\rangle=2\) and \(\langle f,1+x\rangle=3\). Hence, for \(p=a+b(1+x)\),

$$ \begin{bmatrix}1&1\\1&2\end{bmatrix} \begin{bmatrix}a\\b\end{bmatrix} = \begin{bmatrix}2\\3\end{bmatrix}. $$

The equations are \(a+b=2\) and \(a+2b=3\). Subtracting the first from the second gives \(b=1\), and then \(a=1\). Therefore \(p(x)=1+(1+x)=2+x\). Substituting the coefficients back gives \(1+1=2\) and \(1+2=3\), as required.

The residual is \(f-p=x^2\). Its coefficient list is \((0,0,1)\), while those of the basis polynomials are \((1,0,0)\) and \((1,1,0)\). Their dot products with the residual are both zero. This confirms residual orthogonality, and the theorem guarantees that \(2+x\) is the unique closest element of \(S\) for this inner product.

Worked Example: Projection from Values at Three Points

On \(P_2\), use \(\langle g,h\rangle=g(0)h(0)+g(1)h(1)+g(2)h(2)\). This is an inner product: if \(\langle g,g\rangle=0\), then \(g\) vanishes at \(0,1,2\); a polynomial of degree at most \(2\) with three distinct roots must be zero. Project \(f(x)=x^2\) onto \(S=\operatorname{span}\{1,1+x\}\). These basis polynomials are independent as in the first example and are nonorthogonal, since \(\langle1,1+x\rangle=1+2+3=6\).

At \(0,1,2\), the values of \(1\) are \(1,1,1\), those of \(1+x\) are \(1,2,3\), and those of \(f\) are \(0,1,4\). Thus

$$ \mathbf{G}= \begin{bmatrix}3&6\\6&14\end{bmatrix}, \qquad \mathbf{b}= \begin{bmatrix}5\\14\end{bmatrix}. $$

For \(p=a+b(1+x)\), reduce the augmented matrix to solve the equations:

$$ \begin{bmatrix}3&6&\vline&5\\6&14&\vline&14\end{bmatrix} \xrightarrow{R_2\to R_2-2R_1} \begin{bmatrix}3&6&\vline&5\\0&2&\vline&4\end{bmatrix}. $$

The second row gives \(2b=4\), so \(b=2\). The first row then gives \(3a+12=5\), hence \(a=-\frac73\). Therefore \(p(x)=-\frac73+2(1+x)=-\frac13+2x\). Substitution checks both equations: \(3(-\frac73)+6(2)=5\), and \(6(-\frac73)+14(2)=14\).

The residual values at \(0,1,2\) are \(\frac13,-\frac23,\frac13\). Their inner products with the basis are \(\frac13-\frac23+\frac13=0\) and \(\frac13-\frac43+1=0\). The squared error is \((\frac13)^2+(-\frac23)^2+(\frac13)^2=\frac23\). Residual orthogonality and the theorem confirm that this is the unique closest polynomial in \(S\).

A Common Mistake: Treating the Basis as Orthogonal

For an orthogonal basis, dividing \(\langle f,\phi_i\rangle\) by \(\langle\phi_i,\phi_i\rangle\) gives the coefficient in the \(\phi_i\) direction. That separate calculation does not generally work for a nonorthogonal basis: the interactions appear in the off-diagonal Gram entries.

For instance, in the first example, dividing each right-hand entry by the corresponding diagonal Gram entry would give \(a=(\frac23)/2=\frac13\) and \(b=(\frac23)/(\frac83)=\frac14\). But this fails even the first Gram equation: \(2(\frac13)+2(\frac14)=\frac76\ne\frac23\). It also fails residual orthogonality, since the resulting polynomial is \(\frac{7}{12}+\frac{x}{4}\), and the inner product of its residual with \(1\) is \(\frac23-\frac76=-\frac12\), not zero. The correction is to solve the full system, including its off-diagonal entries.

The method is useful whenever a polynomial subspace is specified by a convenient basis that is not orthogonal. The inner product may come from integration, coefficient lists, or evaluations at selected points, provided it is positive definite on the space being used. In each case, the same checks apply: solve the Gram equations, verify that the residual is orthogonal to every basis element, and use the squared-norm decomposition to justify that the answer is closest.

Check Your Understanding

For each question, use the stated inner product and check any proposed projection by testing its residual against the basis.

  1. For \(\langle g,h\rangle=\int_0^1 g(x)h(x)\,dx\), find the projection of \(x^2\) onto \(\operatorname{span}\{1,x\}\) by forming the Gram equations.
  2. In the coefficient inner product on \(P_2\), compute the Gram matrix for the ordered basis \((1,1+x)\). Is it diagonal?
  3. Explain why a Gram matrix built from a basis in a real inner product space has trivial null space.
  4. For the discrete inner product using values at \(0,1,2\), verify that the residual in the third worked example has squared norm \(\frac23\).
  5. Why can separate ratios of right-hand entries to diagonal Gram entries fail to give the projection coefficients?

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon