Dot product in 3D space

Given the 3D vectors $$\vec u,\ \vec v$$, whose coordinates are given for a Cartesian coordinate system:
 * $$\vec u = (u_x,\, u_y,\, u_z)$$,
 * $$\vec v = (v_x,\, v_y,\, v_z)$$,

their dot product may be defined to be
 * $$\vec u \cdot \vec v = u_x v_x + u_y v_y + u_z v_z$$

Let $$\vec w = \vec u \times \vec v$$ be their cross product:
 * $$ \vec w = \begin{vmatrix} \hat i & \hat j & \hat k \\ u_x & u_y & u_z \\ v_x & v_y & v_z \end{vmatrix} $$
 * $$ = (u_y v_z - u_sz v_y,\, u_z v_x - u_x v_z,\, u_x v_y - u_y v_x)$$.

The cross product is perpendicular to both of factors, $$\vec u$$ and $$\vec v$$, as can be verified by taking dot products:
 * $$ \vec u \cdot \vec w = u_x (u_y v_z - u_z v_y) + u_y (u_z v_x - u_x v_z) + u_z (u_x v_y - u_y v_x)$$
 * $$ = u_x u_y v_z - u_x u_z v_y + u_y u_z v_x - u_y u_x v_z + u_z u_x v_y - u_z u_y v_x = 0$$

Assuming that both $$\vec u$$ and $$\vec v$$ are non-zero in length then the cosine of the angle between them yields 0; so the angle between them is a right angle; so $$\vec u$$ and $$\vec w$$ are perpendicular; i.e., $$\vec u$$ and $$\vec u \times \vec v$$ are perpendicular. [But the geometric interpretation for the 3D case has not been shown yet; would not this claim be circular then?]

Exercise: Show that $$\vec v$$ and $$\vec w$$ are perpendicular.

Let $$\hat w$$ be the normalized version of $$\vec w$$, i.e.
 * $$\hat w = {\vec w \over \sqrt{\vec w \cdot \vec w}}$$

so that $$\vec w$$ has unit length, because
 * $$ \hat w \cdot \hat w = {\vec w \cdot \vec w \over \sqrt{\vec w \cdot \vec w}^2} = {\vec w \cdot \vec w \over \vec w \cdot \vec w} = 1 $$

and $$\sqrt{\hat w \cdot \hat w} = \sqrt{1} = 1$$. [Again, this calculation has used the geometric interpretation of the dot product already.]

Let $$\vec u_\perp = \hat w \times \vec u$$, then $$\vec u_\perp$$ has the same length as $$\vec u$$ but is perpendicular to both $$\hat w$$ and $$\vec u$$, so it is a rotation by 90&deg; of $$\vec u$$ in the “$$\perp \! \hat w$$ plane” (the plane whose normal is $$\hat w$$).

Likewise let $$\vec v_\perp = \hat w \times \vec v$$. Let
 * $$ \vec u' = \cos \theta \, \vec u + \sin \theta \, \vec u_\perp $$,
 * $$ \vec v' = \cos \theta \, \vec v + \sin \theta \, \vec v_\perp $$.

Note: $$\vec u'$$ is a rotation of $$\vec u$$ by an angle $$\theta$$ around axis $$\hat w$$. Likewise $$\vec v'$$ is a rotation of $$\vec v$$ by an angle $$\theta$$ around axis $$\hat w$$.


 * $$\vec u' \cdot \vec v' = (\cos \theta \, \vec u + \sin \theta \, \vec u_\perp) \cdot (\cos \theta \, \vec v + \sin \theta \, \vec v_\perp) $$
 * $$ = \cos^2 \theta \, \vec u \cdot \vec v + \cos \theta \sin \theta \, \vec u \cdot \vec v_\perp + \sin \theta \cos \theta \, \vec u_\perp \cdot \vec v + \sin^2 \theta \, \vec u_\perp \cdot \vec v_\perp$$
 * $$ = \cos^2 \theta \, \vec u \cdot \vec v + \sin^2 \theta \, (\hat w \times \vec u) \cdot (\hat w \times \vec v) + \cos \theta \sin \theta \, (\vec u \cdot \hat w \times \vec v + \hat w \times \vec u \cdot \vec v)$$
 * $$ \hat u \cdot \hat w \times \vec v = \begin{vmatrix} u_x & u_y & u_z \\ w_x & w_y & w_z \\ v_x & v_y & v_z \end{vmatrix} $$

($$\hat i,\, \hat j,\, \hat k$$ get replaced by $$u_x,\, u_y,\, u_z$$ due to the dot product; this combination of dot and cross product forming a determinant is called a vector triple product).
 * $$ \hat w \times \vec u \cdot \vec v = \vec v \cdot \hat w \times \vec u$$

because the dot product is commutative.
 * $$ \vec v \cdot \hat w \times \vec u = \begin{vmatrix} v_x & v_y & v_z \\ w_x & w_y & w_z \\ u_x & u_y & u_z \end{vmatrix} $$
 * $$ = - u \cdot \hat w \times \vec v$$

because there is an interchange of rows one and three in the determinant; so swapping two factors of a vector triple product changes its sign.

So $$\vec u \cdot \hat w \times \vec v + \hat w \times \vec u \cdot \vec v = 0$$,
 * $$ \vec u' \cdot \vec v' = \cos^2 \theta \, \vec u \cdot \vec v + \sin^2 \theta \, \vec u_\perp \cdot \vec v_\perp$$

Focusing on the last term (of the right-hand side (RHS)):
 * $$ (\hat w \times \vec u) \cdot (\hat w \times \vec v) = \left({\vec w \over w} \times \vec u\right) \cdot \left({\vec w \over w} \times \vec v \right) $$
 * $$ = {1\over w^2} (\vec w \times \vec u) \cdot (\vec w \times \vec v)$$
 * $$ = {1 \over w^2} ((\vec u \times \vec v) \times \vec u) \cdot ((\vec u \times \vec v) \times \vec v) $$

Summary of the argument coming up ahead: $$\vec u_\perp$$ is a 90&deg; (counterclockwise) rotation of $$\vec u$$ in the $$\perp \! \hat w$$ plane and $$\vec v_\perp$$ is a 90&deg; (counterclockwise) rotation of $$\vec v$$ in the $$\perp \! \hat w$$ plane, so
 * $$ \vec u_\perp \cdot \vec v_\perp = \vec u \cdot \vec v$$

thus $$ \vec u' \cdot \vec v' = \cos^2 \theta \, \vec u \cdot \vec v + \sin^2 \theta \, \vec u \cdot \vec v $$
 * $$ = (\cos^2 \theta + \sin^2 \theta) \, \vec u \cdot \vec v$$
 * $$ \vec u' \cdot \vec v' = \vec u \cdot \vec v$$ (End of summary.)

The products $$(\vec u \times \vec v) \times \vec u $$ and $$ (\vec u \times \vec v) \times \vec v $$ have the general form $$ (\vec b \times \vec c) \times \vec a $$. We will now derive a formula for $$\vec a \times (\vec b \times \vec c)$$.

The double cross product $$\vec a \times (\vec b \times \vec c)$$ has to be perpendicular to $$\vec b \times \vec c$$, so it must be in the plane of both $$\vec b$$ and $$\vec c$$; it must be a linear combination of $$\vec b$$ and $$\vec c$$.
 * $$ \vec b \times \vec c = \begin{vmatrix} \hat i & \hat j & \hat k \\ b_x & b_y & b_z \\ c_x & c_y & c_z \end{vmatrix} $$
 * $$ = (b_y c_z - b_z c_y,\, b_z c_x - b_x c_z,\, b_x c_y - b_y c_x)$$


 * $$\vec a \times (\vec b \times \vec c) = \begin{vmatrix} \hat i & \hat j & \hat k \\ a_x & a_y & a_z \\ b_y c_z - b_z c_y & b_z c_x - b_x c_z & b_x c_y - b_y c_x \end{vmatrix} $$
 * $$ = (a_y b_x c_y - a_y b_y c_x - a_z b_z c_x + a_z b_x c_z, $$
 * $$ a_z b_y c_z - a_z b_z c_y - a_x b_x c_y + a_x b_y c_x, $$
 * $$ a_x b_z c_x - a_x b_x c_z - a_y b_y c_z + a_y b_z c_y)$$
 * $$ = (b_x a_y c_y + b_x a_z c_z - c_x a_y b_y - c_x a_z b_z, $$
 * $$ b_y a_x c_x + b_y a_z c_z - c_y a_x b_x - c_y a_z b_z, $$
 * $$ b_z a_x c_x + b_z a_y c_y - c_z a_x b_x - c_z a_y b_y)$$
 * $$ = (b_x (a_y c_y + a_z c_z) - c_x (a_y b_y + a_z b_z),$$
 * $$ b_y (a_x c_x + a_z c_z) - c_y (a_x b_x + a_z b_z), $$
 * $$ b_z (a_x c_x + a_y c_y) - c_z (a_x b_x + a_y b_y)) $$
 * $$ = (b_x (\underline{a_x c_x} + a_y c_y + a_z c_z) - c_x (\underline{a_x b_x} + a_y b_y + a_z b_z), $$
 * $$ b_y (a_x c_x + \underline{a_y c_y} + a_z c_z) - c_y (a_x b_x + \underline{a_y b_y} + a_z b_z), $$
 * $$ b_z (a_x c_x + a_y c_y + \underline{a_z c_z}) - c_z (a_x b_x + a_y b_y + \underline{a_z c_z}))$$
 * $$ = (b_x \, \vec a \cdot \vec c - c_x \, \vec a \cdot \vec b, $$
 * $$ b_y \, \vec a \cdot \vec c - c_y \, \vec a \cdot \vec b, $$
 * $$ b_z \, \vec a \cdot \vec c - c_z \, \vec a \cdot \vec b)$$
 * $$ = (b_x \, \vec a \cdot \vec c,\, b_y \, \vec a \cdot \vec c,\, b_z \, \vec a \cdot \vec c) - (c_x \, \vec a \cdot \vec b,\, c_y \, \vec a \cdot \vec b,\, c_z \, \vec a \cdot \vec b) $$
 * $$ = \vec a \cdot \vec c \, (b_x,\, b_y,\, b_z) - \vec a \cdot \vec b \, (c_x,\, c_y,\, c_z)$$
 * $$ = (\vec a \cdot \vec c) \vec b - (\vec a \cdot \vec b) \vec c = \vec a \times (\vec b \times \vec c) $$.

Back to the focused-on equation:
 * $$ (\vec u \times \vec v) \times \vec u = - \vec u \times (\vec u \times \vec v) $$
 * $$ = - [ (\vec u \cdot \vec v) \vec u - (\vec u \cdot \vec u) \vec v]$$
 * $$ = u^2 \vec v - (\vec u \cdot \vec v) \vec u $$


 * $$ (\vec u \times \vec v) \times \vec v = - \vec v \times (\vec u \times \vec v) $$
 * $$ = - [ (\vec v \cdot \vec v) \vec u - (\vec v \cdot \vec u) \vec v ]$$
 * $$ = (\vec v \cdot \vec u) \vec v - v^2 \vec u $$

Thus
 * $$ \vec u' \cdot \vec v' = {1\over w^2} ((\vec u \times \vec v) \times u) \cdot ((\vec u \times \vec v) \times \vec v) $$
 * $$ = {1\over w^2} \left\{(u^2 \vec v - (\vec u \cdot \vec v) \vec u) \cdot ((\vec u \cdot \vec v) \vec v - v^2 \vec u) \right\} $$
 * $$ = {1 \over w^2} \left\{ u^2 (\vec u \cdot \vec v) v^2 - u^2 v^2 (\vec u \cdot \vec v) - (\vec u \cdot \vec v)^2 (\vec u \cdot \vec v) + (\vec u \cdot \vec v) v^2 u^2\right\} $$
 * $$ = {1 \over w^2} \left\{ u^2 v^2 (\vec u \cdot \vec v) - (\vec u \cdot \vec v)^3\right\} $$
 * $$ = {\vec u \cdot \vec v \over w^2} \left\{ u^2 v^2 - (\vec u \cdot \vec v)^2\right\} $$


 * $$ w^2 = \vec w \cdot \vec w = (\vec u \times \vec v) \cdot (\vec u \times \vec v) $$

Now the first cross and the dot in the RHS may be swapped, because the product is a vector triple product:
 * $$ w^2 = \vec u \cdot \vec v \times (\vec u \times \vec v) $$

and now there is a double cross product at the end of the RHS, so the formula can be applied:
 * $$ w^2 = \vec u \cdot [(\vec v \cdot \vec v) \vec u - (\vec v \cdot \vec u) \vec v] $$
 * $$ = \vec u \cdot [v^2 \vec u - (\vec v \cdot \vec u) \vec v] $$
 * $$ = [v^2 u^2 - (\vec v \cdot \vec u)^2]$$

Thus
 * $$ {\vec u \cdot \vec v \over w^2} (u^2 v^2 - (\vec u \cdot \vec v)^2) = \vec u \cdot \vec v$$
 * &there4; $$ \vec u_\perp \cdot \vec v_\perp = \vec u \cdot \vec v $$
 * &there4; $$ \vec u' \cdot \vec v' = \vec u \cdot \vec v$$.

So rotating 3D vectors $$\vec u$$ and $$\vec v$$ by the same angle along their common plane leaves their dot product preserved.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Given a pair of 3D vectors $$\vec u$$ and $$\vec v$$, what happens to the dot product $$\vec u \cdot \vec v$$ if $$\vec v$$ is rotated around the axis $$\vec u$$ so that the angle between $$\vec u$$ and $$\vec v$$ is preserved?

Firstly we will derive the Rodrigues formula in order to perform such a rotation. Vector $$\vec v$$ must be analyzed into parts that are parallel and perpendicular to $$\vec u$$: call them $$\vec v_\|$$ and $$\vec v_\perp$$. Firstly consider the normalized version of $$\vec u$$:
 * $$ \hat u = {\vec u \over u} = {\vec u \over \sqrt{\vec u \cdot \vec u}}$$.

The projection of $$\vec v$$ onto the $$\hat u$$ axis is:
 * $$ \vec v_\| = (\vec v \cdot \hat u) \hat u $$

Now subtract $$\vec v_\| $$ from $$\vec v$$ to obtain its perpendicular part:
 * $$ \vec v_\perp = \vec v - \vec v_\| $$

What is $$\vec v_\perp \cdot \hat u$$?
 * $$ \vec v_\perp \cdot \hat u = (\vec v - \vec v_\|) \cdot \hat u$$
 * $$ = (\vec v - \hat u (\vec v \cdot \hat u)) \cdot \hat u $$
 * $$ = \vec v \cdot \hat u - (\hat u \cdot \hat u) (\vec v \cdot \hat u)$$

Since $$\hat u$$ is a unit vector then $$\hat u \cdot \hat u = 1$$, so
 * $$ \vec v_\perp \cdot \hat u = \vec v \cdot \hat u - \vec v \cdot \hat u = 0 $$

which proves that $$\vec v_\perp$$ is perpendicular to $$\hat u$$, as expected. [''Or does it? Has the geometric interpretation of the dot product been established yet? Is not the argument a bit circular?'']


 * $$ \vec v_\perp' = \hat u \times \vec v_\perp $$
 * $$ \vec v' = \vec v_\| + \cos \theta \, \vec v_\perp + \sin \theta \, \vec v'_\perp$$

where $$\theta$$ is the angle of rotation.
 * $$ \vec v' = \vec v_\| + \cos \theta (\vec v - \vec v_\|) + \sin \theta \, \hat u \times (\vec v - \vec v_\|)$$
 * $$ (\vec v \cdot \hat u) \hat u + \cos \theta (\vec v - (\vec v \cdot \hat u) \hat u) + \sin \theta \, \hat u \times (\vec v - (\vec v \cdot \hat u) \hat u) $$
 * $$ (\vec v \cdot \hat u) \hat u + \cos \theta \, (\vec v - (\vec v \cdot \hat u) \hat u) + \sin \theta \, \hat u \times \vec v$$

so a Rodrigues rotation of vector $$\vec v$$ around vector $$\vec u$$ by an angle $$\theta$$ is
 * $$ R_{\vec u,\, \theta} (\vec v') = (1 - \cos \theta) (\vec v \cdot \hat u) \hat u + \cos \theta \, \vec v + \sin \theta \, \hat u \times \vec v$$

Dot-multiplying the just-above by $$\vec u$$ yields
 * $$ \vec u \cdot R_{\vec u,\, \theta} (\vec v') = (1 - \cos \theta) (\vec v \cdot \hat u) (\vec u \cdot \hat u) + \cos \theta \, \vec v \cdot \vec u + \sin \theta \, \vec u \cdot \hat u \times \vec v$$
 * $$ \vec u \cdot \hat u = \vec u \cdot {\vec u \over u} = {u^2 \over u} = u $$
 * $$ \vec u \cdot \hat u \times \vec v = \vec u \times \hat u \cdot \vec v = {1 \over u} \vec u \times \vec u \cdot \vec v = 0 $$

because $$ \vec u \times \vec u = 0 $$ for any $$\vec u$$.


 * $$ \vec u \cdot \vec v' = (1 - \cos \theta) (\vec v \cdot \hat u) u + \cos \theta \, \vec v \cdot \vec u $$
 * $$ = (1 - \cos \theta) (\vec v \cdot \hat u u) + \cos \theta \, \vec v \cdot \vec u$$
 * $$ = (1 - \cos \theta) (\vec v \cdot \vec u) + \cos \theta \, \vec v \cdot \vec u $$
 * $$ = \vec v \cdot \vec u = \vec u \cdot \vec v$$

as claimed.

Any other rotations of a pair of vectors which leave the angle between them unchanged may be composed of these two kinds of rotation already considered: (1) Rodrigues rotation of one vector around the axis of the other vector, which also rotates the plane containing both vectors; and (2) a dual, “isoangular”, simultaneous pair of rotations of both vectors along their common plane, which leaves it fixed.

Both of these kinds of rotations have been shown to preserve the dot product between the two vectors; therefore any angle preserving (and magnitude preserving; but that should be implicit in the term “rotation”) rotational movement of the two vectors also preserves their dot product.

Homogeneity. Multiplying the lengths of $$\vec u$$ and $$\vec v$$. Let $$\vec u' = \lambda \vec u$$, $$\vec v' = \mu \vec v$$, i.e.,
 * $$ \vec u' = (\lambda u_x,\, \lambda u_y,\, \lambda u_z)$$
 * $$ \vec v' = (\mu v_x,\, \mu v_y,\, \mu v_z)$$,

then
 * $$ \vec u' \cdot \vec v' = \lambda \mu u_x v_x + \lambda \mu u_y v_y + \lambda \mu u_z v_z $$
 * $$ = \lambda \mu \, \vec u \cdot \vec v$$.

Multiplying the length of $$\vec u$$ or $$\vec v$$ also multiplies the length of their dot product by the same factor.

What happens when both $$\vec u$$ and $$\vec v$$ are unit vectors? Rotate them in an angle-preserving way so as to place $$\vec u$$ along the x-axis. Then
 * $$ \vec u' = (1,\, 0,\, 0)$$.

Rotate $$\vec v$$ around $$\vec u$$ until $$\vec v$$ is contained by the xy-plane. Then
 * $$\vec v' = (v_x',\, v_y',\, 0) = (\cos \phi,\, \sin \phi,\, 0)$$

for some angle $$\phi$$. The angle $$\phi$$ is now contained within the xy-plane:
 * $$ \vec u' \cdot \vec v' = v_x' = \cos \phi $$.


 * $$ \cos \phi = \vec u \cdot \vec v$$

because the rotation was also dot-product preserving.

For non-unit vectors $$\vec u,\, \vec v$$:
 * $$ \vec u = u \hat u$$,
 * $$ \vec v = v \hat v$$

where $$ u = \sqrt{\vec u \cdot \vec u}$$, $$ v = \sqrt{\vec v \cdot \vec v}$$.
 * $$ \vec u \cdot \vec v = u \hat u \cdot v \hat v = u v \, \hat u \cdot \hat v$$

but $$ \hat u \cdot \hat v = \cos \phi$$ so
 * $$ \vec u \cdot \vec v = u v \, \cos \phi $$

where u and v are the magnitudes of $$\vec u,\, \vec v$$ respectively; and $$\phi$$ is the angle between them. This is the geometric interpretation of the dot product (in 3D; it looks the same as that for the plane).