Methods for generating a basis or extending to basis Which methods can I use to gain a basis and to extend a given subspace of vectors to a basis?
 A: One approach to finding a basis for a finite dimensional vector space $V$ is this:


*

*Let $B = \emptyset$

*If $span(B) = V $, you're done. 

*Otherwise, let $u \in V - span(B)$

*Let $B = B \cup {u}$

*Go to step 2. 
For instance, to find a basis of the space V of polynomials of degree 2 or less, we let $B = \emptyset$. Span(B) is clearly not all of $V$. So we pick an element of $V - span(B)$, i.e., a nonzero polynomial, say $u = 1 + t$. (I could have chosen $u = \pi t^2 - 32t + 7.1$, but I want to save typing!). 
Now span(B) consists of all multiples of $1+t$, which is not all of V. So I pick a polynomial from $V$ that's not in the span ... a quadratic, for instance, like $u = t^2 - 2t + 5$. Now things are a little trickier. Does the span of $B$ contain all possible degree-2-or-less polynomials? Hmmm. The span of $B$ is all polynomials of the form 
$$
a(1 + t) + b(t^2 - 2t + 5) = b t^2 + (a - 2b) t + (a + 5b)
$$
Is there a polynomial that's NOT one of those? Let's see. If we start our polynomial with $t^2 + ...$, then $b$ would have to be $1$. And if we continue it with $t^2 + 0t + ...$, then $a - 2b$ would have to be $0$, so $a$ would have to be $2$ (for the polynomial to be part of span(B)$). That would mean the polynomial would be $t^2 + 0t + 7$ if it was in the span. So if we picked instead $u = t^2 + 0t + 6$, it would not be in the span. Let's do so. We end up with 
$$
B  = \{ 1+t, t^2 - 2t + 5, t^2 + 0t + 6 \}.
$$
At this point, EVERY polynomial of degree two or less is a combination of elements of $B$ --- that takes a little proving --- and so the algorithm quits. We've found a basis. 
How did I know to quit? Well, I can write the polynomial $t^2$ as a combination of elements of $B$. To do so, I write the following:
$$
t^2 = a(1+t) + b(t^2 -2t + 5) + c(t^2 + 0t +6) \\
= a+at + bt^2 -2bt + 5b + ct^2 +6c) \\
= (a+5b + 6c) + (a - 2b)t + (b+c)t^2
$$
For that to be true, I need for $b + c = 1$, $a-2b = 0$ and $a + 5b + 6c = 0$. I solve those three simultaneous equations (one approach: use the first to replace $c$ with $1-b$ in the other two to get
$$
a - 2b = 0 \\
a + 5b + 6(1-b) = 0
$$
which becomes
$$
a - 2b =  0 \\
a -  b = -6
$$
which leads to $b = -6, a = -12, c = 7$.
I can do the same sort of thing to write $t$ as a combination of my three basis elements, and to write the constant polynomial $1$ as a combination of them. But with these three, I can write ANY polynomail $At^2 + Bt + C$ by taking $A$ times my first combination, plus $B$ times my second, plus $C$ times my third. 

One question remains: how do I know that the set $B$ that I've built is a basis? Well, at the end of the algorithm $span(B) = V$. So it's a spanning set. Is it independent? Well, at each stage of the algorithm, it is (this requires a small proof). So it is at the end as well. 
You might want to look at Phil Klein's "Coding the Matrix" (codingthematrix.com) for a discussion of this and other algorithms like it in elementary linear algebra.  
