Proof of the formula $x\cdot y=\| x \| \|y\| \cos(\theta)$ for vectors whose dimensions are larger than 3. How can we prove the formula $x\cdot y=\| x \| \|y\| \cos(\theta)$  for vectors whose dimensions are larger than 3. All the proofs I saw are given for 2D space using a figure such as the one below.

Image source: https://tutorial.math.lamar.edu/classes/calcii/dotproduct.aspx
 A: You can do it using the cosine rule, which is basis free, and doesn't therefore depend on the orientation of the triangle.
Note that Pythagoras gives us that $|a|^2=\sum a_i^2=\vec a\cdot \vec a$ (we can define this as the dot product of a vector with itself, and it ties up also with the definition of the euclidean norm).
Then the cosine rule tells us that:
$$|\vec a - \vec b|^2=|\vec a|^2+|\vec b|^2 - 2 |\vec a|| \vec b| \cos \theta$$
and we can write this using dot products for equal vectors, which we have just defined:
$$(\vec a - \vec b)\cdot (\vec a - \vec b)=\vec a\cdot \vec a+\vec b \cdot \vec b - 2 |\vec a|| \vec b| \cos \theta$$ so that (expanding the left hand side and cancelling the squares and applying distributive and commutative properties) $$-2\vec a\cdot \vec b= -2 |\vec a|| \vec b| \cos \theta$$
And this justifies the definition of $\vec a\cdot \vec b = |a||b|\cos\theta$
Now, if we expand in orthonormal co-ordinates using Pythagoras we have that $$\vec a \cdot \vec a = \sum a_i^2$$ so that $$(\vec a - \vec b)\cdot (\vec a - \vec b)-(\vec a\cdot \vec a+\vec b \cdot \vec b)=\sum (a_i-b_i)^2-\sum a_i^2-\sum b_i^2=$$$$=\sum \left(a_i^2-2a_ib_i+b_i^2-a_i^2-b_i^2\right)=-2\sum a_ib_i$$ so that we can compute $$\vec a\cdot \vec b=\sum a_ib_i$$ consistently and independent of basis and this joins up all the formulae.
The dot product works because of the cosine rule (which is a generalisation of Pythagoras), and both of these are obviously independent of basis (they depend on lengths and angles). The sum of products form with respect to a basis is not so obviously invariant.
There is a great similarity here with the connection between a quadratic form and the associated symmetric bilinear form (and related constructions) in more general contexts.
A: You can reduce it to two dimensions in the following steps:

*

*Show that an euclidean isometry preserves angles (and lengths).

*Show that a linear isometry preserves the dot product.

*Show that for any vectors $u,v$, there is a linear isometry which takes $u,v$ into the plane spanned by the standard basis vectors $e_1,e_2$.


Here is a more fleshed out variant of my answer, using only completely elementary tools.$\newcommand{\bR}{\mathbf R}$
Choose any $n\geq 3$ and let $e_1,\ldots, e_n$ be the standard basis vectors in $\bR^n$. For brevity, given $u,v\in \bR^n$, let us write $u\cdot'v$ for $\lVert u\rVert\lVert v\rVert\cos(\angle uv)$. The goal is to show that $u\cdot v=u\cdot'v$.
Fix any $j\geq 2$ and $\theta\in \bR$ and consider the rotation $R_{j,\theta}$ by $\theta$ around the subspace spanned by $(e_i)_{i\neq 1,j}$. Explicitly, $R_{j,\theta}(e_1)=\cos\theta e_1+\sin\theta e_j$, $R_{j,\theta}(e_j)=-\sin\theta e_1+\cos\theta e_j$, $R_{j,\theta}(e_i)=e_i$ for $i\neq 1,j$.
Then it is easy to check that for any $j,\theta$ and $u,v\in \bR^n$ we have $R_{j,\theta}(u)\cdot R_{j,\theta}(v)=u\cdot v$. Since $R_{j,\theta}$ is linear, it follwos that it is an isometry, so it preserves lengths and angles, and thus also $R_{j,\theta}(u)\cdot' R_{j,\theta}(v)=u\cdot' v$.
Note also that if $u\in \bR^n$, then we can choose $\theta$ such that $R_{j,\theta}(u)\cdot e_j=0$.
Using this, given any $u,v\in \bR^n$, by applying $R_{j,\theta}$ for $j=2,3,\ldots, n$(and appropriate $\theta$) to $u$ and $v$, we obtain $u',v'$ such that $u'=\alpha e_1$, $u\cdot v=u'\cdot v'$ and $u\cdot' v=u'\cdot' v'$. By applying $R_{2,\pi/2}$, we obtain then $u'',v''$ such that $u''=\alpha e_2$ and both dot products are still the same.
Then we apply successive rotations $R_{j,\theta}$ for $j=3,4,\ldots, n$ (note that all of these preserve $u''$, obtaining a $v'''=\beta e_1+\gamma e_2$ such that $u\cdot v=u''\cdot v'''$ and $u\cdot' v=u''\cdot v'''$.
Now, $u'',v'''$ are in the plane, and so (by knowing that in the plane, $\cdot$ and $\cdot'$ coincide), we conclude that
$$
u\cdot v=u''\cdot v'''=u''\cdot' v'''=u\cdot ' v.
$$
