Force along $x$ direction on a bumpy surface Gravitational potential energy near earth is given by$$U(y)=mgy$$
Suppose a bumpy surface is described as $y=\sin(x)$, then $U$ varies with $x$:
$$U(x) = mg\sin x $$
Then the force along $x$ is given by
$$F_x =-\dfrac{\partial U}{\partial x}= -mg\cos x$$
Since gravity is vertical, the only other force is normal force. So I think $F_x$ equals the horizontal component of the normal force.

$$N=mg\cos\theta\\ \Rightarrow N_x = -mg\cos\theta\sin\theta = \dfrac{-mg\cos x}{1+\cos^2x}$$
because $\tan \theta = \dfrac{dy}{dx} = \cos x$
Why is $F_x\ne N_x$ ? What am I doing wrong?

Original question for reference : Why is the force along $x$ not $0$ on the bumpy surface?
 A: 
As you can see from the above example the potential function can be broken into components just like force functions.In the example demonstrated above the actual axis is the diagonal line and the force function has been broken into two components along two axes inclined at $45^°$ to the diagonal axis,consequently the potential function along the diagonal axis also breaks into the two potential functions related to the perpendicular axes.Your question is similar.The mg force acting along the vertical breaks into force components $mgsin\theta$ along the slope of sine curve surface and a normal component to surface $mgcos\theta$ ,the normal reaction from surface exactly balances this normal component of actual force.Now that they've cancelled off exactly only $mgsin\theta$ is in the picture.This force too breaks into horizontal and vertical components further.The horizontal component is $mgsin\theta cos\theta$ which you've also arrived at.You started off in the wrong direction only when you thought that the potential function being expressed only in terms of x will be responsible for forces only in the x direction.Even though the function is solely dependent in x ,it is the total potential energy.It is here that the vertical component of $mgsin\theta$ comes to the frame.$-mgcosx$ is the net force acting on the body and not the component of $mgsin\theta$ working in only horizontal direction ,you need to consider its vertical component as well.
