TITLE: How to tell if two 3D vectors are in the same direction?
QUESTION [9 upvotes]: Given:  

$$AB=\left( \begin{array}{ccc}2\\1\\3\end{array} \right) \;\;\;\; \text{and}\;\;\;\; CD=\left( \begin{array}{ccc}4\\3\\6\end{array} \right).$$ 

Justify if $AB$ has the same direction as $CD$ -- give the explanation.

REPLY [2 votes]: Using the cosine rule
$$A.B = |A||B|cos(t)$$
Note that for same direction  
$$cos(t) = 1.0$$
for opposite direction
$$cos(t) = -1$$
so now we can make a boolean test ( true for approximately the same direction )
$$\frac{A.B}{|A||B|} > 0$$
but that is expensive to calculate as calculating the length of a vector requires a square root. We don't want to do that.
$$\frac{(A.B)^2}{|A|^2|B|^2} > 0$$
or
$$\frac{(A.B)^2}{(A.A)(B.B)} > 0$$