- Define $G: \mathbb{R}^n \rightarrow \mathbb{R}^n$ by $G\left(r, \phi_1, \ldots, \phi_{n-2}, \theta\right)=\left(x_1, \ldots, x_n\right)$ where $$ \begin{aligned} & x_1=r \cos \phi_1, \quad x_2=r \sin \phi_1 \cos \phi_2, \quad x_3=r \sin \phi_1 \sin \phi_2 \cos \phi_3, \ldots \\ & x_{n-1}=r \sin \phi_1 \cdots \sin \phi_{n-2} \cos \phi_1, \quad x_n=r \sin \phi_1 \cdots \sin \phi_{n-2} \sin \theta \end{aligned} $$
Show $G$ maps $\mathbb{R}^n$ onto $\mathbb{R}^n$.
Here is my attempt. We will show by induction, that the map is surjective.
Base Case when n=2, fix $(x,y)\in \mathbb{R}^2$. Then choose $r=\sqrt{x^2+y^2}$. Now, we must find a $\theta$ such that $(x,y)=(r\cos(\theta),r\sin(\theta))$. Thus,
$$\frac{y}{x}=\tan(\theta)$$. Using the $\operatorname{atan2}$ function, we can define the inverse over any point on the plane excluding the origin. We have
$$\operatorname{atan}2(y, x)= \begin{cases}\arctan \left(\frac{y}{x}\right) & \text { if } x>0, \\ \arctan \left(\frac{y}{x}\right)+\pi & \text { if } x<0 \text { and } y \geq 0, \\ \arctan \left(\frac{y}{x}\right)-\pi & \text { if } x<0 \text { and } y<0, \\ +\frac{\pi}{2} & \text { if } x=0 \text { and } y>0, \\ -\frac{\pi}{2} & \text { if } x=0 \text { and } y<0, \\ \text { undefined } & \text { if } x=0 \text { and } y=0 .\end{cases}$$
Thus, choosing $\theta=\operatorname{atan}2(y, x)$, we are done.
Induction Step Fix $(x_1,\dots,x_n,x_{n+1})\in \mathbb{R}^n$. We would like to appeal to the induction step. Choose $r,\varphi_1,\dots,\varphi_{n-2},\theta$ by the induction hypothesis. How can I then select the proper final angle to complete the induction step?
How can I choose this theta to complete the induction step?
Finally, on wikipeida, the following function was obtained for the inverse but I am not sure how they came up with this. We may define a coordinate system in an $n$-dimensional Euclidean space which is analogous to the spherical coordinate system defined for 3 -dimensional Euclidean space, in which the coordinates consist of a radial coordinate $r$, and $n-1$ angular coordinates $\varphi_1, \varphi_2, \ldots \varphi_{n-1}$, where the angles $\varphi_1, \varphi_2, \ldots \varphi_{n-2}$ range over $[0, \pi]$ radians (or over $[0,180]$ degrees) and $\varphi_{n-1}$ ranges over $\left[0,2 \pi\right.$ ) radians (or over $[0,360)$ degrees). If $x_i$ are the Cartesian coordinates, then we may compute $x_1, \ldots x_n$ from $r, \varphi_1, \ldots \varphi_{n-1}$ with: $[4]$ $$ \begin{aligned} x_1 & =r \cos \left(\varphi_1\right) \\ x_2 & =r \sin \left(\varphi_1\right) \cos \left(\varphi_2\right) \\ x_3 & =r \sin \left(\varphi_1\right) \sin \left(\varphi_2\right) \cos \left(\varphi_3\right) \\ & \vdots \\ x_{n-1} & =r \sin \left(\varphi_1\right) \cdots \sin \left(\varphi_{n-2}\right) \cos \left(\varphi_{n-1}\right) \\ x_n & =r \sin \left(\varphi_1\right) \cdots \sin \left(\varphi_{n-2}\right) \sin \left(\varphi_{n-1}\right) . \end{aligned} $$ Except in the special cases described below, the inverse transformation is unique: $$ \begin{aligned} & r=\sqrt{{x_n}^2+x_{n-1}{ }^2+\cdots+x_2{ }^2+x_1{ }^2} \\ & \varphi_1=\operatorname{arccot} \frac{x_1}{\sqrt{x_n{ }^2+x_{n-1}{ }^2+\cdots+x_2^2}} \quad=\arccos \frac{x_1}{\sqrt{x_n{ }^2+x_{n-1}{ }^2+\cdots+x_1^2}} \\ & \varphi_2=\operatorname{arccot} \frac{x_2}{\sqrt{x_n{ }^2+x_{n-1}{ }^2+\cdots+x_3^2}} \quad=\arccos \frac{x_2}{\sqrt{x_n{ }^2+x_{n-1}{ }^2+\cdots+x_2{ }^2}} \\ & \varphi_{n-2}=\operatorname{arccot} \frac{x_{n-2}}{\sqrt{x_n{ }^2+x_{n-1}{ }^2}} \quad \quad=\arccos \frac{x_{n-2}}{\sqrt{x_n{ }^2+x_{n-1}{ }^2+x_{n-2}{ }^2}} \\ & \varphi_{n-1}=2 \operatorname{arccot} \frac{x_{n-1}+\sqrt{x_n^2+x_{n-1}^2}}{x_n} \quad= \begin{cases}\arccos \frac{x_{n-1}}{\sqrt{x_n^2+x_{n-1}{ }^2}} & x_n \geq 0, \\ 2 \pi-\arccos \frac{x_{n-1}}{\sqrt{x_n^2+x_{n-1}{ }^2}} & x_n<0 .\end{cases} \\ & \end{aligned} $$ where if $x_k \neq 0$ for some $k$ but all of $x_{k+1}, \ldots x_n$ are zero then $\varphi_k=0$ when $x_k>0$, and $\varphi_k=\pi$ (180 degrees) when $x_k<0$.
Was this contstruction also obtained inductively? and why do they not use tan but rather cot?