# Building orthogonal vectors

Suppose I have $$N$$ vectors $$v_1, v_2, v_3, ..., v_N$$

I already know that I can build an orthonormal basis with the Gram-Schmidt process, but I need to keep the first three fixed, even if they are not orthogonal, i.e. I would like to build vectors in this way:

• $$q_1 = \frac{v_1}{\left\lVert{v_1}\right\rVert_2}$$
• $$q_2 = \frac{v_2}{\left\lVert{v_2}\right\rVert_2}$$
• $$q_3 = \frac{v_3}{\left\lVert{v_3}\right\rVert_2}$$
• $$q_4$$ orthogonal to $$q_1$$, $$q_2$$, $$q_3$$
• $$q_5$$ orthogonal to $$q_1$$, $$q_2$$, $$q_3$$, $$q_4$$

...

• $$q_N$$ orthogonal to $$q_1$$, $$q_2$$, $$q_3$$, ..., $$q_{N-1}$$

I've tried using the Gram-Schmidt process, but the fact that $$q_1$$, $$q_2$$, $$q_3$$ are not orthogonal invalidates the Gram-Schmidt procedure.

Any suggestions how I could proceed?

• Apply Gram-Schmidt without modification, then, at the very end, simply change the first three vectors to the choices you want. Commented Aug 8, 2022 at 7:21
• @TheoBendit I used your procedure successfully, simple and neat. Commented Aug 10, 2022 at 8:15

$${\bf q_k} = {\bf {\hat q}_k + v} \,\,s.t.\,\, \min_{\bf v}\sum_{l=1}^{k-1} \| {\bf q_l}^t ({\bf {\hat q_k + v}})\|_2^2$$
Where $$\bf \hat q_k$$ is a candidate which for example can be randomized as in the case of Gram-Schmidt.
We may do well to add a small regularizing term $$+\epsilon\|{\bf v}\|_2^2$$ to make sure that we don't end up with $$\bf \hat q_k +v$$ being the zero vector.