1
$\begingroup$

For 2D vectors, computing the vector orthogonal to a given $v$ is straightforwardly done using Cross, as for example shown here.

However, Cross does not seem to work for more than two dimensions, and I couldn't find any function giving a complete set of normal vectors to a given $v$.

For example, I'm looking for a function that, given v={1,0,0}, will give me back {{0,1,0},{0,0,1}}, or some other equivalent set of vectors (that is, I want a basis for the orthogonal space $v^\perp$).

An easy way to do this in 3D is with something like:

normalVecs[v_] := Cross[v, #] & /@ IdentityMatrix@3 // Orthogonalize // Select[Norm@# > 0 &];
normalVecs @ {1, 0, 0}

but using Cross does not generalize to more than 3 dimensions.

What is the best way to do this?

$\endgroup$
  • 2
    $\begingroup$ Isn't it just NullSpace[{v}] that you ask? $\endgroup$ – MeMyselfI Nov 25 '18 at 14:49
  • $\begingroup$ @MeMyselfI Ah! I knew there had to be some function doing this, but didn't think of looking with that name. I think that would be the natural answer to this question $\endgroup$ – glS Nov 25 '18 at 14:51
2
$\begingroup$

general solution

normalVecs[vec_] := Module[{l = Length@vec}, 
Cross[vec,##&@@#]&/@ Subsets[IdentityMatrix@l,{l-2}] //DeleteCases@Table[0,l]]  


normalVecs[{1, 0, 0, 0, 0, 0}]    

{{0,0,0,0,0,1},{0,0,0,0,-1,0},{0,0,0,1,0,0},{0,0,-1,0,0,0},{0,1,0,0,0,0}}

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.