Let's say I have a vector like this: $⟨-2,7,4⟩$
What's the best way to find a perpendicular vector for this?
Right now I'm doing $-2x+7y+4z=0$
And plugging in random values for $x$, $y$, and $z$ until I get $0$. This can't be right, right?
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It only takes a minute to sign up.
Sign up to join this communityLet's say I have a vector like this: $⟨-2,7,4⟩$
What's the best way to find a perpendicular vector for this?
Right now I'm doing $-2x+7y+4z=0$
And plugging in random values for $x$, $y$, and $z$ until I get $0$. This can't be right, right?
You don't need the cross-product, as long as you have a scalar product. Remember, most vector spaces do not have a cross-product, but a lot of them do have a scalar product.
Take any arbitrary vector $\vec{r}$ that is not parallel to the given vector $\vec{v}$.
Then $\vec{q} = \vec{r} - \left(\frac{\vec{r}\cdot\vec{v}}{\vec{v}\cdot\vec{v}}\right) \vec{v}$ will be orthogonal to $\vec{v}$.
To prove this, just show that $\vec{q} \cdot \vec{v} = 0$, which just takes a little bit of algebra.
This process is the basis of the Gram-Schmidt process, an important process in linear algebra.
To answer a question you didn't ask, one might wonder "Is there a nice formula that consumes a unit vector $v = (a,b,c)$ and produces a unit vector perpendicular to $v$?" (Of course, if you have a way to produce a vector perpendicular to $v$, you can always divide by its length to get a UNIT vector.)
If by "nice formula", you mean "a triple of expressions involving $a,b,c$, each of which is a continuous function", then the answer is (somewhat surprisingly) "no".
Such a formula would provide, for each point of the unit sphere (the endpoint of your vector $v$) a vector $w$ which, translated to the tip of $v$, is tangent to the sphere, i.e., you'd get an everywhere nonzero continuous vector field on the unit sphere.
And such a thing cannot exist by the Morse Index Theorem.
This is one of my favorite examples of a nice simple-sounding question being tied to a deep theorem of topology.
Given any vector $(a,b,c)$, with $a,b,c\neq 0$, a fast way to find a perpendicular vector is to consider
$$(-b,a,0) \implies (a,b,c)\cdot (-b,a,0) =-ab+ba+0=0$$
or other similar combination of the components as for example $(-c,0,a)$ or $(0,c,-b)$.
When one or two components are equal to zero, find a perpendicular vector is trivial, e.g. $(a,b,0)\perp (0,0,c)$.
If we are interested to find a triple of orthogonal vectors, starting from one given vector, assuming $a,b,c \neq 0$, we can proceed as follows:
$$v_1=(a,0,0) \quad v_2=0,b,0) \quad v_3=(0,0,c)$$
$$v_1=(a,b,0) \quad v_2=(-b,a,0) \quad v_3=(0,0,c)$$
$$v_1=(a,b,c) \quad v_2=(-b,a,0) \quad v_3=v_1 \times v_2 = (-ac,-bc,a^2+b^2)$$
There are many vectors perpendicular to $(-2,7,4)$. One way to find one would be to take the cross product of $(-2,7,4)$ and a vector not parallel to it, such as $(1,0,0)$. The cross product of two vectors is perpendicular to both of them.
If all you want is just any perpendicular vector whatsoever, then the easiest is to just take the zero vector.
If you want any nonzero vector perpendicular to $v=(v_1,v_2,\ldots, v_n)$, then probably the simplest choice is: if $v_1=0$, then take $w=(1,0,\ldots, 0)$. If $v_1\neq 0$, then take $w=(v_2,-v_1,0,0,\ldots,0)$. If your vectors are complex, take $w=(\bar v_2,-\bar v_1,0,\ldots, 0)$ instead.
Works in arbitrary dimension at least $2$ (in dimension $0$ or $1$ there might be no nonzero perpendicular vectors).
I’m assuming the given vector is not all zeros. Then the steps are:
Find the component that has the smallest magnitude. Replace it by $0$. Swap the other two components, and change the sign of one of them.
So, if your vector is $(-2,7,4)$, then ... The component with smallest magnitude is $-2$. Replace it by zero, which gives $(0,7,4)$. Swap the $7$ and the $4$. This gives $(0,4,7)$. Negate the $7$, which gives $(0,4,-7)$.
Check: $(-2,7,4) \cdot (0,4,-7)=0$.
This is essentially the same process given in another answer, but it’s described in a different way that some people might find easier to understand.
Picking the smallest component to zero out is not absolutely necessary, but if you’re writing computer code, you have to make some definite choice, and this choice always works for non-zero vectors.
And plugging in random values for x, y, and z until I get 0. This can't be right, right?
You have a linear equation. You can solve it using any of the methods that exist for solving systems of linear equations. For instance, since you have three variables and one equation, there are two degrees of freedom for the solution space. You can pick any two variables as free variables and solve the third in terms of those two. For instance, if you choose $x$ and $y$ as the free variables, then you have $4z = 2x-7y$, or $z = \frac x 2-\frac {7y}4$. This tells you that you can pick any values for $x$ and $y$ to get a solution. For instance, if $x = 10$, $y = 4$, then $z= 3$, giving the vector $(10, 4, 3)$. So you can plug in random values for two of the varaibles, and get the third using math.