I am given a set of vectors $S=\{\cos^2(x), \sin^2(x), \cos(2x)\}$ and am asked to find a basis for the space spanned by the set above.
I know the above set is not a basis for this space since the vectors are not linearly independent.
However, I am curious how to generate a basis given a set of vectors in general.
If you can determine if vectors are linear independent, then you can always reduce a spanning list into a basis for the space.
The fact that a list is linearly independent, means that one vector can be expressed as a linear combination of the others. Remove one such vector from the list. If the list is still linearly dependent, remove another such vector. When the list is linearly independent, it will still span the space.
For example, in this example, we know that $$\cos(2x) = \cos(x^2) - \sin(x^2)$$ so we can remove $\cos(2x)$ from the list. This produces the list $$(\cos^2(x), \sin^2(x)).$$ We can see that this list is linearly independent. There are many ways to see this. One quick way is to note that $1 = \cos^2(x) + \sin^2(x)$, hence the constant functions (i.e. functions in $\operatorname{span}(1)$) all belong to the vector space. But, not every vector in the vector space is constant, hence the space must be at least two dimensions.