# Trouble applying gram-schmidt to two vectors

As the title suggest I'm trying to apply the gram-schmidt to two vectors $\{v_1, v_2\}$ in order to find the orthonormal basis $\{q_1, q_2\}$.

$$V_1 = \begin{pmatrix} 1\\ 2\\ 4\\ 2 \end{pmatrix}$$

And

$$V_2 = \begin{pmatrix} -3\\ 4\\ 3\\ 4 \end{pmatrix}$$

$$q_1 = \frac{1}{||v_1||}v_1 = \frac{1}{5} \begin{pmatrix}1\\ 2\\ 4\\ 2\\\end{pmatrix} = \begin{pmatrix}\frac{1}{5}\\ \frac{2}{5}\\ \frac{4}{5}\\ \frac{2}{5}\\\end{pmatrix}$$

$$q_2 = v_2 - Proj_{v_1} v_2 = v_2 - \left(v_2\cdot q_1\right) q_1$$

$$= \begin{pmatrix}1\\ 2\\ 4\\ 2\\\end{pmatrix} - \left(\begin{pmatrix}-3\\ 4\\ 3\\ 4\\\end{pmatrix}\cdot \begin{pmatrix}\frac{1}{5}\\ \frac{2}{5}\\ \frac{4}{5}\\ \frac{2}{5}\\\end{pmatrix}\right) \begin{pmatrix}\frac{1}{5}\\ \frac{2}{5}\\ \frac{4}{5}\\ \frac{2}{5}\\\end{pmatrix}$$

$$= \begin{pmatrix}1\\ 2\\ 4\\ 2\\\end{pmatrix} - 5\begin{pmatrix}\frac{1}{5}\\ \frac{2}{5}\\ \frac{4}{5}\\ \frac{2}{5}\\\end{pmatrix} = \begin{pmatrix}1\\ 2\\ 4\\ 2\\\end{pmatrix} - \begin{pmatrix}1\\ 2\\ 4\\ 2\end{pmatrix} = \begin{pmatrix}0\\ 0\\ 0\\ 0\end{pmatrix} ... wrong! also q_2 / ||q_2|| normalize...$$

If someone could explain to me what I'm doing wrong it would be greatly appreciated.

UPDATE: $$q_1 = \frac{1}{||v_1||}v_1 = \frac{1}{5} \begin{pmatrix}1\\ 2\\ 4\\ 2\\\end{pmatrix} = \begin{pmatrix}\frac{1}{5}\\ \frac{2}{5}\\ \frac{4}{5}\\ \frac{2 }{5}\\\end{pmatrix}$$

$$q_2 = v_2 - Proj_{v_1} v_2 = v_2 - \left(v_2\cdot q_1\right) q_1$$

$$= \begin{pmatrix}-3\\ 4\\ 3\\ 4\end{pmatrix} - \left(\begin{pmatrix}-3\\ 4\\ 3\\ 4\end{pmatrix}\cdot \begin{pmatrix}\frac{1}{5}\\ \frac{2}{5}\\ \frac{4}{5}\\ \frac{2}{5}\\\end{pmatrix}\right) \begin{pmatrix}\frac{1}{5}\\ \frac{2}{5}\\ \frac{4}{5}\\ \frac{2}{5}\\\end{pmatrix}$$

$$= \begin{pmatrix}-3\\ 4\\ 3\\ 4\end{pmatrix} - 5\begin{pmatrix}\frac{1}{5}\\ \frac{2}{5}\\ \frac{4}{5}\\ \frac{2}{5}\\\end{pmatrix} = \begin{pmatrix}-3\\ 4\\ 3\\ 4\end{pmatrix} - \begin{pmatrix}1\\ 2\\ 4\\ 2\end{pmatrix} = \begin{pmatrix}-4\\ 2\\ -1\\ 2\end{pmatrix}$$

Does that look right? Also now I jsut have to divide $q_2$ by $||q_2||$, right? Which is 5 so

$$q_2 = \begin{pmatrix}-4/5\\ 2/5\\ -1/5\\ 2/5\end{pmatrix}$$

• You write $q_2=v_2-\ldots$, but the next line has $v_1-\ldots$. – vadim123 Dec 20 '13 at 3:11

You just made a silly mistake: you wrote $q_2=v_2-(v_2\cdot q_1)q_1$ but you accidentally substituted $v_1$ for the first $v_2$.