I would like to know how the angle between two n-vectors is defined. I mean whether it is unique and how we may compute it (is the inner product a valid method in the n-dimensional space?). I have found very little information on this issue on the internet. Thanks
-
Did you want the acute angle or the obtuse angle (that is, if your vectors weren't perpendicular)? – J. M. ain't a mathematician Jul 23 '11 at 13:40
-
@J.M.: Did you mean the non-reflex ($0\le\theta\le\pi$) angle or the reflex ($\pi\lt\theta\lt2\pi$) angle? – Isaac Jul 23 '11 at 14:55
-
@Isaac: Tsk, I was thinking of "vertical angles" at the time I wrote the comment... so the first one, yes. – J. M. ain't a mathematician Jul 23 '11 at 14:57
5 Answers
If your two vectors $v$ and $w$ are not collinear then they span a two-dimensional plane $E\subset{\mathbb R}^n$. This plane inherits the given scalar product in ${\mathbb R}^n$ and so becomes an ordinary euclidean plane like the sheet of paper you are drawing on. The angles in this plane are related to the scalar product as they are in two-dimensional vector geometry, namely by $$\cos\bigl(\angle(v,w)\bigr)={\langle v, w\rangle\over|v|\ |w|}\ .$$

- 226,825
-
5+1 this is the simplest explanation I've seen for why the law of cosines extends to higher dimensions. – R.. GitHub STOP HELPING ICE Jul 24 '11 at 02:43
-
@christian blatter Would you please give an example in R4 , I was searching for answer for the same question before. – Eng_Boody Apr 18 '20 at 12:38
-
@christianBlatter , I meant that I can't imagine visually the 2D plan where the span represents .. how to prove that algebrically , also what are the value of the R2 and R3 representation of the two vectors in such plan or in 3d space ... ur answer gave me some explaination but can't imagine it – Eng_Boody Apr 18 '20 at 13:16
-
1@Eng_Boody: If you attach two different vectors $v$ and $w$ at the origin of ${\mathbb R}^3$ these vectors span a plane. To this plane belong all vectors $x=\lambda v+\mu w$, $>\lambda$, $\mu\in{\mathbb R}$. Same thing in ${\mathbb R}^4$. – Christian Blatter Apr 18 '20 at 13:46
In the $n$-dimensional real space the angle between two vectors is defined by the inner-product: $$\cos\theta=\frac{\langle v,w \rangle}{||v||\cdot||w||}$$ Where $||v||$ is the length of the vector.

- 15,640
-
4I just want to point out that this is basically taking the Law of cosines and solving for the angle. – Willie Wong Jul 23 '11 at 13:25
While you can certainly compute the angle using the usual inner product formula, it's also possible and perfectly acceptable to use the same flavor of geometric definition of angles as is done in $\mathbb{R}^2$ and $\mathbb{R}^3$. Radially project two given nonzero vectors onto the unit sphere via the map $\vec{x}\to\vec{x}/\|\vec{x}\|$. Any two nonidentical points on a hypersphere determine a unique "great circle" containing both of them; the angle in radians can be defined as the length of the shorter arc between the two. (Of course, this raises the question, "How is arclength defined in higher dimensions?" - but this is moot given that the 2 and 3-dimensional definitions immediately generalize to any dimension.)
Demonstrating the inner product formula works in higher dimensions given this definition is fairly easy: the general idea is to use an orthonormal change-of-base matrix $M$ which takes the plane determined by the great circle containing two unit vectors to the $xy$-plane (inner products are unchanged under $M$'s action: $\langle Mx,My\rangle = \langle x,M^TMy\rangle = \langle x,Iy\rangle=\langle x,y\rangle$) and then the formula's validity is reduced to the two-dimensional case.

- 151,657
Another approach, from Levandosky:
Using the triangle inequality it is possible to make sense of the angle between two vectors in $R^n$. Let $v$ and $w$ be nonzero vectors in $R^n$ and assume that $v$ is not a scalar multiple of $w$. We can associate to this pair of vectors a triangle in the plane with side lengths $A = |v|, B = |w|$, and $C = |v - w|.$ To see that there exists such a triangle we apply the triangle inequality three times .... By the SSS Theorem of plane geometry, all such triangles are congruent. We can therefore define the angle $\theta$ between $v$ and $w$ to be the corresponding angle in any plane triangle with sides of length $|v|$,$|w|$, and $|w-v|$. If $v=cw$ we define $\theta=0$ if $c$ is positive and $\theta=\pi$ if $c$ is negative.

- 537
Here is one way to build up to the notion, proving Cauchy-Schwarz inequality along the way.
Distance: Let $ x = (x_1 , \ldots, x_n)^t \in \mathbb{R}^n $. We know, for $ n = 3 $, length of this vector is $ \sqrt{x_1 ^2 + x_2 ^2 + x_3 ^2} $.
This suggests looking at the quantity $ \| x \| \overset{\text{def}}{=} \sqrt{\sum x_i ^2 } $ (which we expect to behave like length).
Orthogonality: Let $ x,y \in \mathbb{R}^n $ be nonzero. For $ n \leq 3 $ we know $ (x,y \text{ are perpendicular}) $ $ \iff (\text{point } x \text{ is equidistant from points } y, (-y))$ $ \iff (\lVert x - y \rVert = \lVert x - (-y) \rVert )$ expresses perpendicularity in terms of lengths.
This suggests looking at the notion $ (x, y \in \mathbb{R}^n \text{ are orthogonal}) \overset{\text{def}}{\iff} (\lVert x - y \rVert = \lVert x + y \rVert). $
Dot Product: The condition $ \lVert x - y \rVert = \lVert x + y \rVert $ can be rewritten as $ \sum (x_i - y_i)^2 = \sum (x_i + y_i)^2 $, which inturn is $ \sum x_i y_i = 0 $. Also $ \| x \| = \sqrt{\sum x_i x_i} $.
This suggests looking at $ \langle x,y \rangle \overset{\text{def}}{=} \sum x_i y_i $, from which $ (x,y \in \mathbb{R}^n \text{ are orthogonal}) \iff (\langle x,y \rangle = 0) $ and $ \| x \| = \sqrt{ \langle x,x \rangle}. $
[ $\langle \cdot \, , \cdot \rangle $ also has few pleasant properties like $ \langle x,y \rangle = \langle y,x \rangle $, $ \langle v_1 + v_2, w \rangle = \langle v_1 , w \rangle + \langle v_2, w \rangle $, etc. ]
We dont yet have a notion similar to "angle between two vectors"...
Decomposing into perpendicular and parallel vectors:
Let $ x,y \in \mathbb{R}^n $ be nonzero. We'll try decomposing $ x $ as $ x = x_{||} + x_{\perp} $, so that $ x_{||} $ is parallel to $ y $ and $ x_{\perp} $ perpendicular to $ y $.
This amounts to writing $ x = ty + (x-ty) $ where $ \langle x-ty, y \rangle = 0 $. So $ x = \frac{\langle x,y \rangle}{\langle y,y \rangle} y + \left( x - \frac{\langle x, y \rangle}{\langle y,y \rangle} y \right) $ is the required decomposition.
Cauchy-Schwarz: In above setup, $ \| x \| = \sqrt{\langle x_{||} + x_{\perp}, x_{||} + x_{\perp} \rangle} $, which on using $ \langle x_{||}, x_{\perp} \rangle = 0 $ becomes $ \sqrt{\|x_{||}\|^2 + \| x_{\perp}\|^2 } $.
Especially $ \| x \| \geq \| x_{||} \| $ $ = \frac{|\langle x,y \rangle|}{\|y\|^2} \| y \| $ $ = \frac{|\langle x,y \rangle|}{\| y \|} $, that is $ \| x \| \| y \| \geq | \langle x,y \rangle | $.
[ The inequality $ \| x \| \| y \| \geq | \langle x, y \rangle | $ also trivially holds when one of $ x,y $ is $ 0 $ ]
Angles: Let $ x,y \in \mathbb{R}^n $ be nonzero.
For $ n \leq 3 $, we know $ \| x \| | \cos(\theta) | = \| x_{||} \| $, where $ \theta $ is the angle between $ x $ and $ y $. In fact, $ \| x \| \cos(\theta) = \left(\text{sign of scaling factor } \frac{\langle x,y \rangle}{\langle y, y \rangle} \right) \left\| \frac{\langle x,y \rangle}{\langle y,y \rangle} y \right\|. $ That is, $ \cos(\theta) = \frac{\langle x, y \rangle}{\| x \| \| y \|} $.
This suggests defining angle between $ x,y \in \mathbb{R}^n $ as $ \theta \overset{\text{def}}{=} \cos^{-1} \left( \frac{\langle x,y \rangle}{\|x\| \|y\|} \right) \in [0, \pi]. $