0

Project $e^x$ onto $P_2$ with the $L^2$ inner product on $[-1,1]$ using:

a) The monomial basis {$1, x, x^2$}.
b) The Legendre basis {$1,x,\frac{1}{2}(3x^2 - 1)$}.

1 Answers1

1

Let, $$ A_{nm} = \int_{-1}^1 x^n x^m dx, $$

write,

$$ e^x = \sum_{n=0}^2 c_n x^n + (\text{ higher order terms}) $$

our goal is to use the inner product formulas to determine the $c_n$'s. Multiply both sides by $x^p$ and integrate from $[-1,1]$ (this is the inner product with $x^p$).

$$\int_{-1}^1 x^p e^x dx= \int_{-1}^1 x^p \sum_{n=0}^2 c_n x^n dx + (\text{ higher order terms})$$

$$\int_{-1}^1 x^p e^x dx= \sum_{n=0}^2 \int_{-1}^1 x^p x^n dx c_n + (\text{ higher order terms})$$

$$\int_{-1}^1 x^p e^x dx= \sum_{n=0}^2 A_{pn} c_n + (\text{ higher order terms})$$

Define $E_p = \int_{-1}^1 x^p e^x$ and we have,

$$ E_p = \sum_{n=0}^2 A_{pn} c_n + (\text{ higher order terms}),$$

If we neglect the higher order terms we then have the following equation,

$$ E_p = \sum_{n=0}^2 A_{pn} c_n,$$

which can be written in matrix form,

$$ \boxed{E = A c}$$

The vector $E$ and the matrix $A$ are computed from integrals. The vector $c$ contains the unknown coefficients. You can solve for $c$ using ordinary matrix methods (I would do a Cholesky decomposition).

Once you know your function in terms of the monomials you can convert this to a representation in terms of Legendre polynomials using the following procedure.


Suppose we have,

$$ f(x) = 1 + 2 x + 3 x^2 $$

we want to write $f$ as a linear combination of Legendre polynomials. We start wiht the highest order term ($x^2$) and write it in terms of $P_2$.

$$P_2 = \frac12 ( 3 x^2 -1 ) \Leftrightarrow x^2 = \frac13(2P_2+1)$$

$$ f(x) = 1 + 2 x + 3 \frac13(2P_2+1) $$

$$ f(x) = 2 + 2 x + 2P_2 $$

$$ f(x) = 1 + 2 x + 2P_2 $$

$$ f(x) = 1 P_0 + 2 P_1 + 2P_2 $$

Then the projection of $f(x)$ onto $P_2$ is the coefficient $2$.


For part $(b)$ equation will be

$$e^x = \sum_{n=0}^2 c_n P_n(x) + (\text{higher order terms})$$

Multiply both sides by $P_m(x)$ and integrate over the interval $[-1,1]$.

$$e^x P_m(x) = \sum_{n=0}^2 c_n P_n(x) P_m(x) + (\text{higher order terms})$$

$$\int_{-1}^1 e^x P_m(x) \mathrm{d}x = \int_{-1}^1 \sum_{n=0}^2 c_n P_n(x) P_m(x) \mathrm{d}x + (\text{higher order terms})$$

$$\color{blue}{\int_{-1}^1 e^x P_m(x) \mathrm{d}x} = \sum_{n=0}^2 c_n \color{blue}{\int_{-1}^1 P_n(x) P_m(x) \mathrm{d}x} + (\text{higher order terms})$$

We will label the integral on the left as $E_m$ and the integral on the right as $A_{nm}$.

$$\color{blue}{E_m} = \sum_{n=0}^2 c_n \color{blue}{A_{nm}} + (\text{higher order terms})$$

Lets neglect the higher order terms.

$$E_m = \sum_{n=0}^2 c_n A_{nm} $$

This is equivalent to the matrix equation,

$$ E = A c$$

Spencer
  • 12,271
  • I know I don't understand some basic concept here. Wher did you get the $x^nx^m$ ? – Vishnu P Oct 29 '19 at 14:52
  • Notice that I end up with an integration of $\int x^p x^n \mathrm{d}x$? The whole idea of the $A_{nm}$ matrix is to just give this integral a convenient label. – Spencer Oct 29 '19 at 16:40
  • I assume this is coming up in the context of a class. If you can provide more details in terms of what specific methods you are being taught I can improve the answer. – Spencer Oct 29 '19 at 16:41
  • Also please note that in the second part of my answer the $f(x)$ is just an example to show how to convert from a monomial basis to the Legendre polynomials. In your case the coefficients of the monomials will be different. – Spencer Oct 29 '19 at 16:42
  • The $A_{nm}$ matrix is something you will run into whenever your basis isn't orthonormal. If it is orthonormal you won't even notice that its there because it will just reduce to the identity matrix. – Spencer Oct 29 '19 at 16:44