If the derivative of $f:R^m\to R^m$ is isometric then $f$ is isometric I can't finish this problem
Let $f:R^m\to R^m$ be a $C^1$ function such that for all $x\in R^m$, $f'(x):R^m\to R^m$ is an isometry i.e. $|f'(x)v|=|v|$ for all $v\in R^m$. Prove that $f$ is an isometry, i.e. that $|f(x)-f(y)|=|x-y|$ for all $x,y\in R^m$. Conclude that there is a linear isometry $T:R^m\to R^m$ and $a\in R^m$ such that $f(x)=Tx+a$ for all $x\in R^m$.
This is what I've done:
Since $|f'(x)v|=|v|$ for all $x,v$ we have that $|f'(x)|=1$. The mean value inequality then says that $|f(x)-f(y)|\le 1\cdot |x-y|=|x-y|$. Ideally one would like to apply the previous inequality with $f^{-1}$ in place of $f$ but we don't know that $f$ is bijective. I tried to use the inverse function theorem but it only assures the inverse of $f$ when $f$ is restricted to some open sets.
So how would one prove that $f$ is bijective?. After that I think i can finish the problem.
 A: Claim: For every $x_0 \in \mathbb{R}^m$ there is a neighborhood $U$ of $x_0$ such that for any $x_1,x_2 \in U$ we have $\|f(x_1) - f(x_2)\| = \|x_1 - x_2\|.$
Proof:
We need the following fact, if $ U \subset \mathbb{R}^m$ is open and convex and $h : U \to \mathbb{R}^m$ is $C^{1}$ then $\|h(x_1) - h(x_2) \| \leq M(x_1,x_2) \| x_1 - x_2 \|$ where $M$ is the upper bound of $\|h'(x)\|$ on the line joining $x_1$ and $x_2.$
Since $f^{'}(x)$ is an isometry, this means $\|f^{'}(x)\| = 1$ for all $x \in \mathbb{R}^m$ and so for any $x_1,x_2 \in \mathbb{R}^m$ $\|f(x_1)  - f(x_2)\| \leq \|x_1 - x_2\|.$
From the inverse mapping theorem we know that for any $x_0 \in \mathbb{R}^m$ there is an open set $U$ which contains $x_0$ and an open ball $V = B(f(x_0),\delta)$ in $\mathbb{R}^m$ such that $V = f(U)$ and the mapping $f:U\to V$ is a smooth bijection and the inverse mapping $g:V\to U$  is $C^{1}$. 
For any $y \in V$ $g'(y) = (f^{'}(g(y)))^{-1}$ is also an isometry since the inverse of an orthogonal matrix is another orthogonal matrix, so $\|g^{'}(y)\| = 1$ for all $y \in V.$
Choose $x_1,x_2 \in U$ and let $y_1 = f(x_1), y_2 = f(x_2)$, $y_1,y_2 \in V.$ Since $V$ is convex, we have $\|x_1 - x_2 \| = \|g(y_1) - g(y_2)\| \leq \|y_1 - y_2\| = \|f(x_1) - f(x_2)\| \leq \|x_1 - x_2\|.$ So for all $x_1,x_2 \in U$ we have $\|f(x_1) - f(x_2)\| = \|x_1 - x_2\|.$
The means for every $x_0 \in \mathbb{R}^m$ there is a neighborhood of $x_0$ in which $f$ is a isometry.
Claim: The second derivative of $f$ vanishes everywhere.
Proof:
Assume $f(0) = 0$. There is a neighborhood of $0$ say $U = B(0,\delta)$ on which $f$ is an isometry.
For any $x \in U$ we have $\| f(x) \| = \| f(x) - f(0) \| = \|x - 0\| = \|x\|$. 
Choose any $x,y \in U$ : we have $\|f(x) - f(y)\|^2 = \|x-y\|^2$ expanding both sides we have $\|f(x)\|^2 + \|f(y)\|^2 -2 \langle f(x),f(y) \rangle = \|x\|^2 + \|y\|^2 - 2\langle x,y \rangle$ so $\langle f(x), f(y) \rangle = \langle x , y \rangle$. So $f$ preserves norms and inner products for $x,y \in U$.
Now choose $x_1,x_2,\dots,x_m \in U$ such that they form a basis of $\mathbb{R}^m.$ Let $\alpha_1,\dots,\alpha_m \in \mathbb{R}$ be such that $|\alpha_1| + \dots + |\alpha_m| \leq 1.$ Now $\|\alpha_1 x_1 + \dots + \alpha_m x_m \| \leq |\alpha_1| \|x_1\| + \dots + |\alpha_m| \|x_m\| < (|\alpha_1| + \dots + |\alpha_m|) \delta \leq \delta.$ So $\alpha_1 x_1 + \dots + \alpha_m x_m \in U$.
Let $u = \alpha_1 x_1 + \dots + \alpha_m x_m \in U.$
Now consider $\| f(u) - \sum_{i=1}^{m} \alpha_i f(x_i)\|^2 = \|f(u)\|^2 + \sum_{i=1}^{m}\sum_{j=1}^{m}\alpha_i\alpha_j \langle f(x_i),f(x_j) \rangle - 2 \sum_{i=1}^M \alpha_i \langle f(u),f(x_i)\rangle = \|u\|^2 + \sum_{i=1}^{m}\sum_{j=1}^m \alpha_i \alpha_j \langle x_i,x_j \rangle - 2\langle \sum_{i=1}^{m}\alpha_ix_i,u\rangle = \|u\|^2 + \|u\|^2 - 2\|u\|^2 = 0.$
So $f(\alpha_1 x_1 + \dots + \alpha_m x_m) = \alpha_1 f(x_1) + \dots + \alpha_m f(x_m).$
Now, any sufficiently small $u \in \mathbb{R}^m$ can be written as $u = \alpha_1 x_1 + \alpha_2 x_m + \dots + \alpha_m x_m$ where $|\alpha_1| + |\alpha_2| + \dots + |\alpha_m| \leq 1$.  To see this let $X$ be the matrix with columns $x_1,\dots,x_m$ and let $u$ be any vector with $\|u\| \leq \dfrac{1}{\sqrt{m}\|X^{-1}\|}.$ Then $u = \sum_{i=1}\alpha_i x_i $ implies $X\alpha = u$ where $\alpha = (\alpha_1,\dots,\alpha_m)^T$ so $\alpha = X^{-1}u$, and $\|\alpha\| \leq \|X^{-1}\| \|u\| \leq \dfrac{1}{\sqrt{m}}$, and by Cauchy-Schwarz $\sum_{i=1}^{m} |\alpha_i| \leq \sqrt{m} \|\alpha\| \leq 1.$
So for small $u$ $f$ coincides the linear map which sends $\alpha_1 x_1 + \alpha_2 x_m + \dots + \alpha_m x_m \to \alpha_1 f(x_1) + \alpha_2 f(x_2) + \dots \alpha_m f(x_m) $ . In matrix terms this means for sufficiently small $u$ we have $f(u) = B\alpha = BX^{-1}u$ where $X$ is the matrix with columns $x_1,\dots,x_m$ and $B$ is the matrix with columns $f(x_1),\dots,f(x_m).$ This implies the second derivative of $f$ at $0$ must be $0$.
Now for the general case, choose any $x_0 \in \mathbb{R}^m$ consider the function $r(x) = f(x_0 + x) - f(x_0)$. Clearly $r$ is smooth $r'(x)$ is an isometry for all $x$, and $r(0) = 0$. This means the second derivative of $r$ at $0$ and hence the derivative of $f$ at $x_0$ is $0$. Since $x_0$ was arbitrary, the derivative of $f$ vanishes everywhere, i.e., if $f=(f_1,f_2,\dots,f_m)$ then for all $x$ we have $D_{i,j}f_k(x) = 0$ where $D_{i,j}f_k$ denotes the $(i,j)^{\text{th}}$ mixed derivative of $f_k$.
Claim: f is linear.
Proof:
 Choose any $u \in \mathbb{R^m}$ and any $v \in \mathbb{R^m}$, define $h:\mathbb{R}\to \mathbb{R}$ as $h(t) = \langle v, f(tu) \rangle$. We have $h^{'}(t) = \langle v, f^{'}(tu)u \rangle$ and $h^{''}(t) = t^2\sum_{i,j,k=1}^{m} D_{i,j}f_k(tu) u_i u_j v_k = 0$. Here $D_{ij}f_k(tu)$ denotes the $i,j$^{th} mixed derivative of $f_k$ (where $f = (f_1,f_2,\dots,f_m) $)and is $0$.
So we must have $h(t) = h(0) + h^{'}(0) t$, in particular, $h(1) = h(0) + h^{'}(0)$, i.e., $ \langle v , f(u) \rangle = \langle  v,f(0) \rangle  + \langle v,f^{'}(0)u\rangle$. So $\langle  v , f(u) - f(0) - f^{'}(0)u \rangle  = 0$ for all $v$ for a given $u$. In paritcular if we choose $v = f(u) - f(0) - f^{'}(0)u$ we get $\|f(u) - f(0) - f^{'}(0)u\|^2 = 0$  so $f(u) = f(0) + f^{'}(0)u.$ Since $u$ is arbitrary, $f$ must be linear.
Finally, since it is given that $f^{'}(0)$ is an isometry, $f$ also must be an isometry.
