# Finding a vector for an orthonormal basis after using gram-schmidt.

So I started with a basis for $P_3$ (polynomial of degree less than 3). $$\{1,x,x^2\}$$ which has inner product define as $$\langle p,q \rangle=p(-1)q(-1)+p(0)q(0)+p(1)q(1)$$

For this product I found an orthonormal basis, $U$ as follows: $$u_1=\frac{1}{||1||}=\frac{1}{\sqrt{\langle1,1\rangle}}=\frac{1}{\sqrt{3}}$$ $$u_2=\frac{x-p_1}{||x-p_1||} \quad\quad p_1=\langle x,u_1 \rangle u_1$$ $$u_2=\frac{x}{\sqrt2}$$ $$u_3=\frac{x^2-p_2}{||x^2-p_2||} \quad\quad p_2=\langle x^2,u_1 \rangle u_1 + \langle x^2,u_2 \rangle u_2=\frac{2}{3}$$ $$u_3=\frac{x^2-\frac{2}{3}}{||x^2-\frac{2}{3}||}$$ $$u_3=\sqrt\frac{3}{2}x^2-\sqrt\frac{2}{3}$$

Therefore the orthonormal basis is $$U=\left\{ \frac{1}{\sqrt3},\frac{x}{\sqrt2},\sqrt\frac{3}{2}x^2-\sqrt\frac{2}{3} \right\}$$

Now I need to fine the polynomial $1+x+x^2$ in this new basis and here is where I'm having trouble. I can easily get $\{\sqrt3, \sqrt2, \dots\}$ but how do I get the last vector?

Let the scalar to be multiplied with be $z$. Then presumably $$z\left(\sqrt\frac{3}{2}x^2-\sqrt\frac{2}{3}\right)=x^2$$

But this means that $z$ is not a scalar but is a function of $x^2$ so I'm definitely doing something wrong but I don't know what.

## 1 Answer

To verify your result, I just calculated $\langle 1,1\rangle=3$, $\ \langle 1,x\rangle=0=\langle x^2,x\rangle\$ and $\ \langle x^2,1\rangle=2$.
So that, the first two basis vectors are indeed multiples of $1$ and $x$ as they are already 'orthogonal' to each other, and $(x^2-2/3)$ is 'orthogonal' to both $1$ and $x$.

Now to answer your question, there are more ways to write $1+x+x^2$ in this new basis. Start it from the highest term: the coefficient of $x^2$ can only arrive from $u_3$, and hence it must be $\sqrt{2/3}$. Can you carry on from here?

Alternatively, as we are talking about orthonormal basis, the $i$th coordinate of any element $v$ will be exactly $\langle v,u_i\rangle$ w.r.t. basis $u_1,u_2,\dots$.
Use it for $v=1+x+x^2$.