Understanding a Gram-Schmidt example
Mia Lopez
Here's the thing: my textbook has an example of using the Gram Schmidt process with an integral. It is stated thus:
Let $V = P(R)$ with the inner product $\langle f(x), g(x) \rangle = \int^{1}_{-1}f(t)g(t)dt$.
Consider the subspace $P_2(R)$ with the standard ordered basis $\beta$. We use the Gram Schmidt process to replace $\beta$ by an orthogonal basis {$v_1, v_2, v_3$} for $P_2(R)$ and the use this orthogonal to obtain an orthonormal basis for $P_2(R)$.
OK, so far so good. But here's where I have trouble following. The text says:
take $v_1 = 1$. (This is presumably the first part of the basis).
Then it says: $\rVert v_1\rVert^2= \int^1_{-1}1^2dt = 2$ and $\langle x,v_1 \rangle = \int^1_{-1}t \dot\ 1\ dt = 0$
and that's where I am a little lost. If the standard ordered basis they are talking about here is {$1, x, x^2$} then it makes a bit more sense but I am just trying to follow the steps. Is that what is happening here? Something else?
$\endgroup$2 Answers
$\begingroup$You're correct. The standard basis for $P_2(R)$ is $\beta = \{1,x,x^2\}$, as you said, and the author is starting with $\beta$ and following the Gram-Schmidt algorithm to generate an orthogonal basis.
In reply to your comment:Let me answer your questions about the inner product first. The author has introduced an important type of inner product here. Since the elements of $P_2(R)$ are integrable functions, we can define the inner product of two vectors $f(x),g(x) \in P_2(R)$ as$$ \langle f(x),g(x) \rangle = \int_{-1}^1 f(t)g(t) \,dt. $$So for example, the inner product of $v = 1-3x + 2x^2$ and $w = 5 + 8x$ is\begin{align} \langle 1-3x + 2x^2, 5 + 8x \rangle &= \int_{-1}^1 (1 - 3t + 2t^2)(5 + 8t) \,dt \\ &= \int_{-1}^1 5+t+2 t^2+160 t^3 \,dt = \frac{2}{3} \end{align}I'll leave it up to you to verify that this is actually an inner product (worth checking, if you haven't already). (Also, in case you were wondering: the choice of bounds $\pm 1$ doesn't really matter here; if you choose any $a$ and $b$ with $-\infty < a < b < \infty$ you get a new inner product $\langle f(x), g(x)\rangle_{a,b} = \int_a^b f(t)g(t) dt$ on $P_2(R)$!)
So to answer one of your questions, yes, you just substitute $1$ for both $f(x)$ and $g(x)$ when computing $\|v_1\|$ ($=\|1\|$):$$ \|v_1\| = \langle v_1,v_1\rangle^{1/2} = \langle1,1\rangle^{1/2} = \left(\int_{-1}^1 1 \cdot 1 \,dt\right)^{1/2}. $$
Summary:Following the Gram-Schmidt process to generate an orthogonal basis $\{v_1,v_2,v_3\}$ from the ordered basis $\beta = \{1,x,x^2\}$, we obtain the following vectors:\begin{align} v_1 &= 1 \text{ (since $1$ = the first vector in $\beta$)} \\ v_2 &= x - \text{proj}_{v_1}(x) = x - \text{proj}_{1}(x) \\ &= x - \frac{\langle x, 1 \rangle}{\langle 1, 1 \rangle} \cdot 1 = x - \frac{0}{2} \cdot 1 = x \\ v_3 &= x^2 - \text{proj}_{v_1}(x^2) - \text{proj}_{v_2}(x^2) \\ &= x^2 - \frac{ \langle x^2, 1 \rangle }{ \langle 1, 1 \rangle } \cdot 1 - \frac{ \langle x^2, x \rangle }{ \langle x, x \rangle } \cdot x \\ &= x^2 - \frac{ \int_{-1}^1 t^2 \cdot 1 \,dt }{ \int_{-1}^1 1 \cdot 1 \,dt } \cdot 1 - \frac{ \int_{-1}^1 t^2 \cdot t \,dt }{ \int_{-1}^1 t \cdot t \,dt } \cdot x = x^2 - \frac{2/3}{2} \cdot 1 - \frac{0}{2/3} \cdot x = x^2 - \frac{1}{3}. \end{align}In other words, our new orthogonal basis is$$ B = \{v_1,v_2,v_3\}. $$If you haven't before, it's worth thinking through why this gives you an orthogonal basis (and validating your conceptual understanding by confirming that $\langle v_i, v_j \rangle = 0$ for $i \neq j$.
We've gotten through the labor-intensive part of Gram-Schmidt. Since $B$ is an orthogonal basis, we can arrive at an orthonormal basis $\{u_1, u_2, u_3\}$ by simply dividing each of the vectors $v_i$ by its norm $\|v_i\| = \sqrt{\langle v_i, v_i \rangle}$. This is easily done after having calculated $B$, since you can reduce calculating $\|v_i\|$ into taking the square root of a sum of mostly known inner product values. The resulting orthonormal basis $\{u_1, u_2, u_3\}$ is\begin{align*} u_1 &= v_1/\|v_1\| = 1/\|1\| = 1/\sqrt{2} \\ u_2 &= v_2/\|v_2\| = x/\|x\| = x/\left(\int_{-1}^1 t^2 \,dt\right)^{1/2} = \frac{1}{\sqrt{2/3}}x = \sqrt{\frac{3}{2}}x \\ u_3 &= v_3/\|v_3\| = \frac{x^2 - 1/3}{\left(\int_{-1}^1 (t^2 - 1/3)^2 \,dt\right)^{1/2}} = \frac{3\sqrt{5}}{2\sqrt{2}} \left(x^2 - \frac{1}{3}\right) = \frac{3\sqrt{5}}{2\sqrt{2}} x^2 - \frac{\sqrt{5}}{2\sqrt{2}} \end{align*}
Edit: As @lojle and @RayBern both noticed, I accidentally omitted a projection term when calculating $v_3$. I've corrected the error and revised the surrounding commentary accordingly.
$\endgroup$ 5 $\begingroup$Previous Dan's answer was very nice and he explained it well, but he missed out a detail which could potentially confuse many future readers, so I decided to do the correction.
When you use Gram-Schmidt algorithm to find the (ortho)normal basis $\left\{e_1, e_2, e_3\dots\right\}$ from the standard basis $\beta = \left\{v_1,v_2,v_3\dots\right\}$, you must take care to take away components of all the vectors $e_i$ that you have already found. So in this example we would have:
$v_1' = 1\quad$ (first vector from $\beta$, not yet normalized)
To normalize it we have to use our inner product definition: $\langle f(x), g(x) \rangle = \int^{1}_{-1}f(t)g(t)dt \quad$ and: $\Vert x\Vert^2 = \langle x, x\rangle$
$$e_1 = \frac{v_1'}{\sqrt{\langle v_1', v_1'\rangle}} = \frac1{\sqrt{\int^1_{-1}1dt}} = \frac1{\sqrt2}$$
$$v_2' = v_2 - \langle e_1, v_2\rangle \ e_1 = t - \frac1{\sqrt2} \ \int^1_{-1}\frac1{\sqrt2}tdt = t$$$$\Rightarrow e_2 = \frac{t}{\sqrt{\int^1_{-1}t^2dt}} = \sqrt{\frac32}\ t$$
Now comes the important bit. We must take away both $e_1$ and $e_2$ components from $v_3'$.$$v_3' = v_3 - \langle e_1, v_3\rangle \ e_1 - \langle e_2, v_3\rangle \ e_2$$$$\Rightarrow v_3' = t^2 -\frac12 \int^1_{-1}t^2dt - \frac32 t\int^1_{-1}t^3dt = t^2 - \frac13$$Since $$\int^1_{-1}\left(t^2-\frac13\right)^2 = \frac8{45} \Rightarrow\quad e_3 = \sqrt{\frac{45}8} \left(t^2 - \frac13\right)$$So you get a new basis diferent from $\beta$. You could also use the general formula for finding new orthonormal basis vectors. Suppose you already found $e_1\dots e_i$ vectors. To find $i+1$-st vector you would use:$$e_{i+1} = v_{i+1} - \sum_{k=1}^i \langle e_k, v_{i+1} \rangle e_k$$
$\endgroup$