# Given a set of four linearly independent vectors, how can I compute two additional linearly independent vectors?

I have four linearly independent vectors:

$$\left( \begin{array}{c} \left\{\frac{1}{2},\frac{1}{2},0,0,0,0\right\} \\ \end{array} \right)$$ $$\left( \begin{array}{c} \left\{\frac{1}{2 \sqrt{3}},-\frac{1}{2 \sqrt{3}},0,0,0,0\right\} \\ \end{array} \right)$$

$$\left( \begin{array}{c} \left\{0,0,0,0,0,\frac{1}{2}\right\} \\ \end{array} \right)$$

$$\left( \begin{array}{c} \left\{-\frac{1}{3},-\frac{2}{3},-1,-1,-1,-\frac{1}{2}\right\} \\ \end{array} \right)$$

What is the easiest way to compute with Mathematica two more linearly independent vectors, such that I have a complete basis for my vector space?

• If working over the reals, say, you could just pick two random vectors. (And if the result is not a complete basis, shoot your rng.) – Daniel Lichtblau Jul 24 '15 at 13:34
• @Daniel Please meet my cousin, Dr. Murphy. – Dr. belisarius Jul 24 '15 at 13:36
• @Belisarius Are you by chance also related to Cole? – Daniel Lichtblau Jul 24 '15 at 13:39
• @Daniel, his law is delicious! – J. M.'s technical difficulties Jul 27 '15 at 2:34

b = {{1, 1, 0, 0, 0, 0}, {1, -1, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 1},
{-1, -2, -3, -3, -3, -3/2}};
h = NullSpace@b

(* {{0, 0, -1, 0, 1, 0}, {0, 0, -1, 1, 0, 0}} *

MatrixRank@Join[b, h]
(* 6 *)

• …this is pretty much the textbook solution. :) Had the given number been five instead of four, taking the Cross[] of those five vectors would yield the sixth independent one. – J. M.'s technical difficulties Jul 24 '15 at 12:33
• @Guesswhoitis. I remember falling in love with this one many years ago. We were both so young then! – Dr. belisarius Jul 24 '15 at 13:26
• ah… :) to be honest, I only appreciated this stuff way after I was no longer in school and took it upon myself to properly learn the damn thing. That book helped a great deal. – J. M.'s technical difficulties Jul 24 '15 at 13:30

As an extended side note,

p = Map[KroneckerProduct[#, #] &] @ Map[Normalize] @ vecs;
(* You can use Orthogonalize instead of Map[Normalize], too *)


generates a projection matrix that projects any matrix onto your known subspace, and it can be used to subtract off that piece. Examining this matrix,

p
(* {{1, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0},
{0, 0, 1/3, 1/3, 1/3, 0},
{0, 0, 1/3, 1/3, 1/3, 0},
{0, 0, 1/3, 1/3, 1/3, 0},
{0, 0, 0, 0, 0, 1}}
*)


we see a set of vectors that the solution needs to be orthogonal to. The block in the middle is of particular importance, since in three space, this is just {1,1,1}. So, the solution is the plane orthogonal to that vector.

• Orthogonalize[] would be closer to the textbook approach (Gram-Schmidt), actually. – J. M.'s technical difficulties Jul 24 '15 at 12:53
• @Guesswhoitis. of course it would, but I was checking that if I retained the less restrictive linear independence, instead of orthogonality, that we would get the same result. It did, so I left it in. – rcollyer Jul 24 '15 at 12:55
• @Guesswhoitis. often, though, that form is not taught in linear algebra classes, but it becomes crystal clear if you spend to much time with the bra/ket formalism. :P – rcollyer Jul 24 '15 at 12:59
• That's funny; back when I was still learning linear algebra in school, the professor thumbed his nose at the physicists by saying he'd rather eat worms than discuss brackets just as he was discussing Gram-Schmidt in full generality (e.g. at that point, he had already mentioned the Legendre polynomials). Come to think of it… I suppose Projection[] is also usable here. – J. M.'s technical difficulties Jul 24 '15 at 13:05
• @Guesswhoitis. (Ah, one of those functions that I knew in theory existed, but never used.) When GS was discussed, we always encountered it with the form $\vec{a} - \vec{b} (\vec{a}\cdot\vec{b})$, and it wasn't until I made a concerted study of vector spaces in physics that a lot of things fell into place. I think a serious advantage of bra-kets is the ability to instantly grasp what is being discussed by it structure on the page. Obviously, you eventually have to resort to other schemes (raised and lowered indices) to deal with more complex issues, but I digress. – rcollyer Jul 24 '15 at 13:13