Using the Lagrangian to find the equations of motion for a ball on an arbitrary hill If a ball is on a hill with height $h$ defined by $h(x)$, then I'd like to find the equations of motion. The ball is in a uniform gravitational field. This is supposed to be compared to the situation in which $h(x) = U(x)$, and I am to evaluate under what limit the two scenarios become identical.
I actually began by trying to write out the Newton's 2nd Law equations, but this proved to be very unpleasant to look at. I ended up with something like
$$\ddot{x} = \frac{g}{\sqrt{h'(x)^2+1}},\ \ \ddot{y} = g\left(\frac{h'(x)}{\sqrt{h'(x)^2+1}} - 1\right)$$
I know that $y = h(x)$, but pulling apart the time and space derivatives felt more cumbersome than necessary.
So I figured the Lagrangian would be kinder.
Since I know $y = h(x)$, there is only one degree of freedom, and the Lagrangian and E-L equations are as follows (I neglected $m$ because it falls away).
$$L = \frac{1}{2}\left(\dot{x}^2 + \dot{h}(x)^2\right)^{1/2} - gh(x)$$
The E-L equations are where I am getting mixed up. I know $h$ is a function of $x$, but $\dot{h}$ could be a function of both $x$ and $\dot{x}$. At any rate:
$$\frac{\partial L}{\partial x} = -gh'(x)$$
$$\frac{d}{dt} \frac{\partial L}{\partial \dot{x}} = \frac{d}{dt}\left(\frac{1}{2}(\dot{x} + \dot{h})\left(\dot{x}^2 + \dot{h}(x)^2\right)^{-1/2}\right)$$
And now it looks extremely unpleasant. I heard this method was supposed to be very clean and easy, but I suspect I've forgotten something fundamental. I'm not sure where to go from here.
 A: The question is more or less answered by the comments, but since there is no answer posted yet I'll post my answer anyway.
OP asks how to find the equations of motion of a point mass $m$ confined to a 1-dimensional curve parametrized by $y = h(x)$. He already came up with the idea of using the Lagrange formalism, which I will use in this answer. As usual we first parametrize the position vector $\mathbf r$ in terms of the chosen coordinates (Here I will just use the $x$-coordinate.). The position vector depending on the $x$-coordinate is given by
$$
\mathbf r(t) = \begin{pmatrix}x(t)\\h(x(t))\end{pmatrix} .
$$
Hence the velocity of the point mass is given by
$$
\dot{\mathbf{r}} (t)= \begin{pmatrix}\dot x(t)\\h'(x(t)) \dot x(t)\end{pmatrix} ,
$$
where I use the notation $h'(x) = \frac{\text{d}h}{\text{d}x}(x)$ and $\dot x (t) = \frac{\text{d}x}{\text{d}t}(t)$. To get the Lagrangian of the system we compute
$$
\begin{align}
L(\mathbf r, \dot{\mathbf{r}}) &= T(\dot{\mathbf{r}}) - U(\mathbf{r})\\
&= \frac m 2 \dot{\mathbf{r}} ^2 - mg\ \mathbf r \cdot \mathbf{e}_z\\
&=\frac m 2(\dot x ^2 + h'(x)^2\dot x ^2) - mg\ h(x)\\
&=\frac m 2 \dot x ^2 (1 + h'(x)^2) - mg\ h(x)
\end{align}
$$
Using the Euler-Lagrange-Equation
$$
\frac{\text{d}}{\text{d}t} \frac{\partial L}{\partial \dot x} - \frac{\partial L}{\partial x} = 0
$$
we get the EOMs, which I leave as an exercise. Note however that $h$ and $h'$ depend on $x$ which has to be taken into account! (In the comments OP seems to be thinking that $h'$ is dependent on $\dot x$ but since $h$ was supposed to depend only on $x$, which makes sense in the context, $h'$ is also only a function of $x$. Remember $h' = d/dx\ h$)
A: I think @AlmostClueless answer already solves the problem, but I can suggest you a slightly different approach, which is actually the same but without Lagrangian formalism.
It consists of writing the enrgy of your particle, taking its time derivative and assemblying things together using the condition $y=h(x)$.
It might be helpful next time you encounter an (effectively) 1D problem but don't have Euler-Lagrange equation by hand.
If you write the energy of your particle you get a term accounting for the kinetic energy
$$K={1\over 2}m(v_x^2+v_y^2)$$
and a potential energy term
$$U=mgh(x)$$
depending only on the height $h(x)$ (and of course on mass $m$ and gravity $g$).
So your total energy is
$$E={1\over 2}m(v_x^2+v_y^2)+mgh(x)$$
and because energy is conserved, if we take the time derivative of everything
$$0 = {1\over 2}m(2v_x{dv_x\over dt}+2v_y{dv_y\over dt})+mgh'(x){dx\over dt}=$$
$$=m(v_xa_x+v_ya_y)+mgh'(x)v_x$$
Of course in doing this we used $h'(x)={dh\over dx}$ and $a_x={dv_x\over dt}$
Now we use that $y=h(x)$ so $$v_y={dh(x)\over dt}={dh\over dx}{dx\over dt}=h'(x)v_x$$
and finally
$$a_y={dv_y\over dt}=h'(x)a_x+h''(x)v_x^2$$
with $h''(x)={dh'(x)\over dt}$.
Which means that our derivative of the energy can be written as
$$0 = m(v_xa_x+v_ya_y)+mgh'(x)v_x=$$
$$=m\left(v_xa_x+h'(x)v_x(h'(x)a_x+h''(x)v_x^2)\right) +mgh'(x)v_x=$$
$$=m\left(v_xa_x+h'(x)^2v_xa_x+h'(x)h''(x)v_x^3\right) + mgh'(x)v_x=0$$
from which finally, eliminating $v_x\ne 0$ (we only loose the solutions where $v_x=0$) and solving for $a_x$
$$ a_x= h'(x)\left({g+h''(x)v_x^2  \over  1+h'(x)^2}\right)$$
Which is exactly the same you would get from the Euler-Langrange equation.
Of course, from before,
$$a_y=h'(x)a_x+h''(x)v_x^2$$
of simply, after solving for $x$
$$y(t)=h(x(t))$$
A: 
I actually began by trying to write out the Newton's 2nd Law equations, but this proved to be very unpleasant to look at.

I don't think so
starting with the position vector
$$\boldsymbol R=\left[ \begin {array}{c} x\\ h \left( x \right) 
\end {array} \right] 
$$
you obtain the velocity
$$\boldsymbol{\dot{R}}= \left[ \begin {array}{c} 1\\ {\frac {d}{dx}}h
 \left( x \right) \end {array} \right] 
\,\dot{x}=\boldsymbol J\,\dot{x}$$
and the acceleration
$$\boldsymbol{\ddot{R}}=\boldsymbol J\,\ddot{x}+
\underbrace{\left[ \begin {array}{c} 0\\   \left( {\frac {d^{2}}
{d{x}^{2}}}h \left( x \right)  \right) {{\dot x}}^{2}\end {array}
 \right]}_{\boldsymbol f_z} $$
substitute the acceleration into $m\,\boldsymbol{\ddot{R}}=\boldsymbol  f_a+\boldsymbol f_c$
eliminate the constraint forces   $~\boldsymbol f_c~$ by multiplaying from the left with $~\boldsymbol J^T~$  you obtain the
the equations of motion.
$$m\,\boldsymbol J^T\,\boldsymbol J\,\ddot{x}=
-\boldsymbol J^T\,\left(m\,g\boldsymbol{\hat e}_y+m\,\boldsymbol f_z\right)$$
