Should diffeomorphisms preserving arc length be affine? Problem
Suppose $\varphi\colon V=\mathbb R^n\to V$ be a differmorphism and $d\varphi$ is its tangent mapping. $\langle\circ,\circ\rangle$ is a nondegenerate (symmetric or symplectic) bilinear form on $V$. If $d\varphi$ preserves the scalar product everywhere, i.e. $\langle u,v\rangle=\langle d\varphi_x(u),d\varphi_x(v)\rangle$ for all $x\in V$ and $u,v\in V$ (identify $T_xV$ with $V$), should $\varphi$ be affine?
Thoughts
Suppose $\langle\circ,\circ\rangle$ is an inner-product, the result seems true, for it's not hard to show that $\varphi$ preserves arc length by curvilinear integral, then if $l_{pq}$ is the segment connecting $p$ and $q$ of the minimal distance, then $\varphi(l_{pq})$ connects $\varphi(p)$ and $\varphi(q)$ of the minimal distance, hence $l_{\varphi(p)\varphi(q)}$.
Backgrounds
The problem arises from the twin paradox in special relativity. The frame of reference of the traveling twin isn't inertial therefore isn't equivalent to the inertial frame of reference on earth, thus the time dilation argument is nonsense. Mathematically, if the coordinate system of the spacetime in which the frame of reference isn't inertial, we cannot determine the proper time of a world line naïvely from integrating $c^{-1}ds=\sqrt{dt^2-c^{-2}(x^2+y^2+z^2)}$ in the new coordinate system, i.e, the arc length of the world line isn't preserved under the coordinate transformation.
Any idea? Thanks!
Edit
The symplectic case is already disproved by Seub.
 A: I think this is a good question, I wish I understood more deeply how things work in a more general setting. Anyway here's what I can tell you:
If $\langle \cdot, \cdot \rangle$ is an inner product (positive definite)
Yes, it is true that a map $f : V \rightarrow V$ (say ${\cal C}^1$) whose tangent mapping preserves the inner product everywhere (in other words a Riemannian isometry) must be an affine isometry of $V$.
Here's a sketch of proof (maybe there is a more direct proof, I'm not sure):
(1) $f$ preserves the lengths of piecewise-${\cal C}^1$ paths
(2) therefore $f$ preserves distances between points
(3) therefore $f$ is an affine isometry.
(1) is immediate by assumption on $f$ and the formula giving the length of a ${\cal C}^1$ path: $L(\gamma) = \int_a^b \Vert \gamma'(t) \Vert dt$
(2) is an immediate consequence of (1) and the following fact: the distance between two points $x$ and $y$ (given by $d(x,y) = \Vert x - y \Vert$) is the minimum of the length of all piecewise-${\cal C}^1$ paths between $x$ and $y$. In two words, this fact is proved as follows: it's true that the length of a polygonal path between $x$ and $y$ is greater than $d(x,y)$, this is a consequence of the triangle inequality. Then approximate a ${\cal C}^1$ path by polygonal paths.
(3) After taking a couple compositions with translations, we can assume that $f$ fixes the origin. By (2), $f$ preserves the norm on $V$ ($\Vert f(x) \Vert = \Vert x \Vert $ for all $x$) and thus the inner product too (by the polarization identity). It follows that $f$ is linear: given vectors $x$, $y$ and a scalar $\lambda$, check that $\langle f(\lambda x + y) - \lambda f(x) - f(y), v \rangle = 0$ for all $v$ and conclude.
If $\langle \cdot, \cdot \rangle$ is skew-symmetric (i.e. a linear symplectic structrue)
Then no, it is not true that any map $f : V \rightarrow V$ whose tangent mapping preserves the linear symplectic structure everywhere (in other words a symplectomorphism) must be an affine symplectic automorphism of $V$.
Take a look at dimension $2$. A symplectomorphism of $\mathbb{R}^2$ is just an area-preserving map. There's tons of those (most of which are not affine). Here's an example that comes to mind "geometrically": take any function $t : \mathbb{R} \rightarrow \mathbb{R}$ and let $f(x,y) = (x, y + t(x))$. Check that $f$ is a symplectomorphism of $\mathbb{R}^2$.
Comments
Here's a natural question: in the first case, where exactly did we use the fact that $\langle \cdot, \cdot \rangle$ is an inner product? Well,
- We used non-degeneracy to show that "$f$ preserves $\langle \cdot, \cdot \rangle$ implies that $f$ is linear"
- We used symmetry for the identity polarization
- We used "positiveness" for the triangle inequality
I think the result is still true if we drop the "positiveness" condition (while keeping non-degeneracy), in other words if we are talking about isometries for a flat pseudo-Riemannian metric on $V$. But I'm not sure how one would prove it.
Comments about the failure for the symplectic case: differential geometers are familiar with the fact that there are a couple of key differences between Riemannian and symplectic geometry. Here's one: all symplectic manifolds of the same dimension are locally isomorphic (see Darboux's theorem), while Riemannian manifolds have local invariants such as curvature. As a result, in contrast to the Riemannian case where the group of isometries of a Riemannian manifold is always a finite-dimensional Lie group, the group of symplectomorphisms of a symplectic manifold is always very large. For example, you can produce a lot of symplectomorphisms by taking the flow of Hamiltonian vector fields. In more elementary terms for our problem: take any function $f : V \to \mathbb{R}$. Let $X_f$ be the symplectic gradient (or Hamiltonian) of $f$, i.e. the unique vector field always satisfying $\langle X_f, v\rangle = df(v)$. Then the flow of $X_f$ is a one-parameter family of symplectomorphisms of $V$.
I'd like to finish this long-winded answer by extending the scope of the question a little bit: let $G$ be a subgroup of $GL(V)$. Let's call it a rigid group if the following holds: any map $f : V \to V$ that fixes the origin and whose differential $df_x$ at any point $x\in V$ is an element of $G$ must be an element of $G$ itself. Under what conditions is $G$ a rigid group? We've seen the cases where $G$ is an orthogonal group or a symplectic group. Here's another example: when $G$ is the group of similitudes of $\mathbb{R}^2$, we are talking about holomorphic functions. Of course this is one way to extend the question, there are probably more relevant and interesting ways to do it.
A: Yes, $\varphi$ should be affine. 
1st proof: assume $\varphi$ is $C^2$ and define  $T_{ijk}=\langle \partial_i\partial_j\varphi, \partial_k\varphi\rangle$ (I use $\partial_i$ for ${\partial\over \partial x_i}$). Then $T_{ijk}$ is symmetric in $ij$ and anti-symmetric in $jk$ (apply $\partial_i$ to $\langle\partial_j\varphi, \partial_k\varphi\rangle=\langle\partial_j, \partial_k\rangle$). 
It follows that $T_{ijk}=0$ (proof: $T_{ijk}=-T_{ikj}=-T_{kij}=\ldots=-T_{ijk}$). 
Hence $\partial_i\partial_j\varphi=0$ (this is where we use that the inner product is non degenerate), so $\partial_j\varphi$ is constant and  $\varphi$ is affine. 
Note that we only used the fact that the inner product is non-degenerate, but not necessarily positive definite. Also, this argument works even if $\varphi$ is defined only locally (ie in some open subset of $V$). However we need $\varphi$ to be $C^2$. 
2nd proof (less elementary, but more geometric). We can find an affine isometry, say $A$, such that $\tilde\varphi:=A\circ\varphi$ satisfies $\tilde\varphi(0)=0,$ $d\tilde\varphi_0=id$ (take $A(x)=(d\varphi_0)^{-1}x-\varphi(0)$). 
I claim that $\tilde\varphi=id$. Let $x\in V$. Define  $\gamma:[0,1]\to V$ by $\gamma(t)=tx.$ Then $\gamma$ is a geodesic. Hence $\tilde\gamma:=\tilde\varphi\circ\gamma$ is also a geodesic (note that $\tilde\varphi$ is an isometry, as a composition of isometries). But  $\tilde\gamma(0)=\gamma(0)=0,$ $\dot{\tilde\gamma}(0)=\dot \gamma(0)=x,$ and both satisfy the same 2nd order ODE, hence $\tilde\gamma=\gamma.$ In particular, $x=\gamma(1)=\tilde\gamma(1)=\tilde\varphi(x)$. 
Hence $\tilde\varphi=id,$ thus $\varphi=A^{-1}$ and is affine. 
