I want to model the dynamic behaviour of a point-mass particle moving along a 2D surface given by $h(x_1,x_2)$. I made a question in physics stack exchange, where i found the error in my modelling, and it had to do with the change of coordinates. I provide the link of that post. ( https://physics.stackexchange.com/questions/706973/lagrange-equation-of-motions-for-a-particle-moving-in-a-surface-in-the-presence#comment1582721_707239 )
I want to go from the relative coordinates $x_{r1},x_{r2}$ to the global coordinates $x_1,x_2$. This, would allow me to write the langrangian using the local coordinates ($x_{r1},x_{r2}$), which is very easy to write, and then change the variables to the global, fixed, frame of reference.
What i originally did: I equated the norms of the vectors ( $x,x_r$ are vectors: $x=(x_1,x_2), x_r = (x_{r1},x_{r2} )$: $$ || x || = cos(\theta(x)) ||x_r||$$ where: $$ cos(\theta(x)) = \frac{1}{\sqrt{1 + || \nabla h(x) ||^2} }$$ I had written the kinetic term of the lagrangian as $ T = \frac{1}{2}m(x_{r1}^2+x_{r2}^2) = \frac{1}{2}m||x_{r}||^2 $ and then i changed the coordinates and ended up with: $$ T = \frac{1}{2}m(1 + || \nabla h(x) ||^2)(x_{1}^2+x_{2}^2) = \frac{1}{2}m(1 + || \nabla h(x) ||^2)||x||^2 $$
However, as it seems from the accepted answer in the original post, the correct lagrangian has the following kinetic term: $$ T = \frac{1}{2}m(||x||^2 + || \nabla h(x) \cdot x ||^2)$$
So, how should i do the transformation?
extra1 in the 1D case, i could do
$$ x_{1} = cos(\theta (x) ) x_{r} = \frac{1}{\sqrt{ 1+ h'(x_1)^2}} x_r $$

extra2 As it is apparent from the figure of the 1D case, $x_{r,i}$ do not point in the same dirrection.
The problem was to transform from curvilinear coordinates to cartesian ones. Wikipedia has this article which is very helpful, especially the section "Constructing a covariant basis in one dimension". As in the 1d case, we have the following equation, which relates the infitesimal displacements in each coordinate system: $$ dx_{r,i} = \sqrt{ 1+ \frac{ \partial h}{\partial x_i}^2 } dx_i $$
(in general we could have $x_{ri} = f(x)$ and not just $x_{ri} = f(x_i)$. In that case, the Jacobian wouldn't be diagonal). This equation, relates the two coordinate systems. If you find the jacobian of this expression, you have the transformation matrix: $$ x_r = J x $$ So, i can express the kinetic energy as i did, and then change the variables according to that transformation rule. BTW, this particular jacobian is:
$$ J = \left [\matrix{ \sqrt{ 1+ \frac{ \partial h}{\partial x_1}^2 } & 0 \cr 0 & \sqrt{ 1+ \frac{ \partial h}{\partial x_2}^2 } } \right ]$$