Orthogonal projection problem. Use the orthonormal set of Legendre polynomials given below to obtain the orthogonal projection of the function f(x) = e2x onto the span of these polynomials. Plot both the function and the (quadratic) projection.
Solution The (real) inner product and norm are
< f, g > = ∫ −11 f(x)g(x)dx and
||f|| = (∫ −11
f(x)2dx)½.
The set of orthonormal Legendre polynomials of
degree 0, 1, and 2 are
p0(x) = 2-1/2, p1(x) = (3/2)1/2x, and p2(x)= (5/8)1/2(3x2-1).
The projection p, which is a quadratic, is found by applying Theorem 0.18 in the text; it has the form
p(x) = < f, p0> p0(x) + < f, p1> p1(x) + < f, p2> p2(x).
The inner products are all integrals of products of polynomials and exponentials; doing them results in these values:
< f, p0> = 8-1/2(e2 -
e-2)
< f, p1> = (3/32)1/2(e2 +
3e-2)
< f, p2> = (5/128)1/2(e2 -
13e-2)
The orthogonal projection, p(x), which is called the quadratic
least-squares fit for f(x), is
p(x) = (1/4)(e2 - e-2) + (3/8)(e2 +
3e-2)x + (5/32)(e2 -
13e-2)(3x2-1).
We now want to use Matlab to create the required plot. Plotting e2x is easy. To plot the polynomials, we will do the following steps.