# Finding a unit vector perpendicular to another vector

For example we have the vector $8i + 4j - 6k$, how can we find a unit vector perpendicular to this vector?

• Very nice. Here's an extension which requests that the unit vector has rational components. Commented Dec 16, 2020 at 22:18

Let $$\vec{v}=x\vec{i}+y\vec{j}+z\vec{k}$$, a perpendicular vector to yours. Their inner product (the dot product - $$\vec{u}.\vec{v}$$ ) should be equal to 0, therefore: $$8x+4y-6z=0 \tag{1}$$ Choose for example x,y and find z from equation 1. In order to make its length equal to 1, calculate $$\|\vec{v}\|=\sqrt{x^2+y^2+z^2}$$ and divide $$\vec{v}$$ with it. Your unit vector would be: $$\vec{u}=\frac{\vec{v}}{\|\vec{v}\|}$$

• "Choose for example x,y .." - cannot both be 0 (zero) Commented Feb 16, 2017 at 8:23
• Your recipe fails if the coefficient for $z$ is zero. Commented Mar 29, 2019 at 9:29
• @ walter, then choose only $x$ and find $y$. Commented Jan 14, 2021 at 10:40

Congrats on 10'000+ views! I'd like to combine the above fine answers into an algorithm.

Given a vector $\vec x$ not identically zero, one way to find $\vec y$ such that $\vec x^T \vec y = 0$ is:

1. start with $\vec y' = \vec 0$ (all zeros);
2. find $m$ such that $x_m \neq 0$, and pick any other index $n \neq m$;
3. set $y'_n = x_m$ and $y'_m = -x_n$, setting potentially two elements of $\vec y'$ non-zero (maybe one if $x_n=0$, doesn't matter);
4. and finally normalize your vector to unit length: $\vec y = \frac{\vec y'}{\|\vec y'\|}.$

(I'm referring to the $n$th element of a vector $\vec v$ as $v_n$.)

• This is the best answer here. Commented Feb 8, 2018 at 20:36

Every answer here gives the equation $8a+4b-6c=0$. None mentions that this equation represents a plane perpendicular to the given vector. I am sure that the omission was an oversight of each respondent. But it deserves mention and emphasis. In the plane perpendicular to any vector, the set of vectors of unit length forms a circle. So answers will vary. The vectors $(-1,2,0)^t$ and $(2,0,3)^t$ can be chosen to be a basis for the solution space of the plane: solve for a, divide by 8, and let $2b$ and $3c$ be independent variables. You can divide each by its length $\sqrt{5}$ and $\sqrt{13}$ respectively, and take a trigonometric combination of them to get a general solution.

An automated procedure:

Take a standard vector $$\vec e_k$$ which is not parallel to $$\vec v$$, and form the cross product $$\vec e_k\times\vec v$$, which is guaranteed to be orthogonal to $$\vec v$$.

The crux of the method is to take the $$\vec e_k$$ which is "the less parallel" to $$\vec v$$, i.e. that minimizes the dot product: take the index $$k$$ corresponding to the smallest $$|v_k|$$, and you are on the safe side.

Update:

In $$d$$ dimensions, take the standard vector $$\vec e_k$$ that forms the smallest dot product (in absolute value) with $$\vec v$$ and normalize the vector

$$\vec e_k-\frac{\vec e_k\vec v}{\|v\|^2}\vec v=\vec e_k-\frac{v_k}{\|v\|^2}\vec v.$$

• Thank you for thinking outside the box! Of course, any vector not parallel to v will produce a perpendicular when crossed with v. This is actually a better answer than most because it is a direct computation, no equation solving required. Commented May 23, 2018 at 3:50
• This only works for 3D vectors, though. Commented Mar 29, 2019 at 9:52
• Don't you mean smallest dot product for the general d-dimensional case? Commented Apr 22, 2019 at 23:53
• @sellibitze: yep, thanks for the notice. Fixing.
– user65203
Commented Apr 23, 2019 at 6:40

I want to add an answer for only two dimensions since it's much more simple:

If our vector is $$v = ai + bj$$ We can easily calculate the normal of $$v$$, because the normal of a vector is perpendicular to it. $$n = -bi + aj$$ $$n$$ is now a perpendicular vector to the vector v, it just has to be normalized, which is explained in other answers already. $$n \rightarrow \frac{n}{\lVert n \rVert}$$

• Welcome to MSE. How will your answer help someone who is interested in working with a vector with $3$ non-zero components? Commented Sep 13, 2021 at 12:18
• @JoséCarlosSantos It doesn't, but in the question, the OP doesn't explicitly say he only wants answers for vectors with 3 components, he only gave an example. Since there are many answers already, I wanted to add a simpler answer in case someone is working with vectors with only 2 components. Commented Sep 13, 2021 at 12:28

Two steps:

First, find a vector $a\,{\bf i}+b\,{\bf j}+c\,{\bf k}$ that is perpendicular to $8\,{\bf i}+4\,{\bf j}-6\,{\bf k}$. (Set the dot product of the two equal to 0 and solve. You can actually set $a$ and $b$ equal to 1 here, and solve for $c$.)

Then divide that vector by its length to make it a unit vector. This unit vector will still be perpendicular to $8\,{\bf i}+4\,{\bf j}-6\,{\bf k}$ .

A vector $v=ai+bj+ck$ is perpendicular to $w=8i+4j-6k$ if and only if $$v\cdot w=8a+4b-6c=0.$$ So for example, we could choose $a=1,b=1,c=2$, so that $v=i+j+2k$. But this is not a unit vector: $$\|v\|=\sqrt{a^2+b^2+c^2}=\sqrt{1^2+1^2+2^2}=\sqrt{6}.$$ However, for any number $t$, it is the case that $\|tv\|=|t|\cdot\|v\|$, and $(tv)\cdot w=t(v\cdot w)$. This shows us how to modify our vector $v$ to get a unit vector that still retains the property of being perpendicular to $w$. Specifically, $$u=\frac{1}{\sqrt{6}}\cdot v=\left(\frac{1}{\sqrt{6}}\right)i+\left(\frac{1}{\sqrt{6}}\right)j+\left(\frac{2}{\sqrt{6}}\right)k$$ satisfies $$\|u\|=\frac{1}{\sqrt{6}}\|v\|=\frac{1}{\sqrt{6}}\cdot\sqrt{6}=1,$$ so that $u$ is unit vector, and $$u\cdot w=\frac{1}{\sqrt{6}}(v\cdot w)=\frac{1}{\sqrt{6}}\cdot0=0,$$ so that $u$ is perpendicular to $w=8i+4j-6k$.

You are just looking to a vector $(x,y,z)$ s.t. $8x+4y-6z=0$. Take $(1,-2,0)$ for example, and then divide it by its norm to make it unit. Another method is that from any non-colinear vector to the first, you can apply Gramm-Schmidt process to get an orthogonal vector from the second.

THEORY:- Suppose 2 vectors A(given) and B,we need to find vector B such that it is Perpendicular to vector A. We also know that A.B=0 (since angle b/w them is 90° and cos(90°)=0. The below described algorithm can be applied for 2D as well as 3D vectors.

Proof:- Given A (8i+4j-6k) Total 3 steps.

Step 1:- Suppose a vector B (i+j+k).

Step 2:- Now firstly compare and divide the coefficient of each unit vector in B with that of A. As in this case, => B=(1/8)i+(1/4)j+(1/-6)k.

Step 3:- Now multiply any one of the three coefficient of unit vector in B with (-2). As in this case i have multiplied (-2) with the coefficient of j.It can be done with i or k also. ** => B=(1/8)i+(1/4)j+(1/3)k. Now for the Unit Vector we can divide vector B with its magnitude, which would be in this case, => |B|= √(1/8)² +(1/4)² +(1/3)²

**=> Unit (B)=B/|B|

** (B) IS THE VECTOR PERPENDICULAR TO A. ** Unit(B) IS THE REQUIRED UNIT VECTOR. Verification:-This can be verified as A.B=0

Proved. :)

• Please use MathJax. Commented Dec 25, 2015 at 19:36
• @Silvia Ghinassi: i actually am not aware about it,what is it? Commented Dec 26, 2015 at 7:21
• @KrishnaMaheshwari can you see well behaved math symbols making post pleasant to read, that is MathJax. Please read more about Commented Oct 8, 2017 at 23:14

In d dimensions, take any random vector $$w$$ which is not parallel to $$v$$, then $$u=w-\frac{v^Tw}{||v||^2}v$$ is orthogonal to the vector $$v$$. It doesn't have to be a standard vector (or that forms the smallest dot product).