how to extend a basis

An easy solution, if you are familiar with this, is the following:

Put the two vectors as rows in a $2 \times 5$ matrix $A$. Find a basis for the null space $\operatorname{Null}(A)$. Then, the three vectors in the basis complete your basis.


I usually do this in an ad hoc way depending on what vectors I already have. However, if you want an algorithm, you can exploit algorithms to reduce a spanning set to a basis (hopefully you know some of these).

In your example, expand your set of vectors to $v_1,v_2,e_1,e_2,e_3,e_4,e_5$, where $e_1,\dotsc,e_5$ are the standard basis vectors in $\mathbb{R}^5$. Then you can apply the sifting algorithm to this set to get a basis; because $v_1$ and $v_2$ are linearly independent and occur first in the list, they won't be removed in the sifting process, so you'll end up with some basis containing them. Essentially the same trick works for set of linearly independent vectors in a finite dimensional vector space.


Put your independent vectors in a list, which you then complete with a generating set for the whole space, as described in the answer by Matt Pressland (the standard basis is the most obvious choice for a generating set for $\Bbb R^n$). Now for each vector in the list in turn, see if the set of vectors in the list up to and including it is linearly dependent. If it is, keep the vector, if it isn't (then this vector must be a linear combination of the previous ones so) throw it out. In either case proceed to the next vector in the list. The test ensures that whenever one advances, the vectors retained so far are linearly independent. Also the vectors thrown out are ensured not to affect the span of the whole list, and since that span was the whole space at the beginning, it still is at the end. By linear dependence, one has found a basis. Since the vectors given initially were independent and at the beginning of the list, none of them can have been thrown out, so they survive in the basis.