you would indeed have to calculate a number using Math.sin(y), y being the top position. here's the catch: if you are using sin, you will more than likely run into an issue with the image jumping left or right when y is reset. that is more than likely going to be the obstacle to overcome here.
Since Math.sin(y) will return a number between -1 and 1, you can multiply that by the max number of differentiation + 1 to get an actual pixel amount to offset the image on each interval.
in simpler terms, differentiation is the distance in pixels that you want the image to move left or right.
edit: after a bit more research, maybe a formula similar to
x = Math.sin(y*w)
w is the number of complete oscillations occur in an amount of time. in your case, 1 should be enough, so you can use the following to get a horizontal motion of 100 pixels in each direction
x = Math.sin(y)*100
you will have to round the number to an integer to be used as pixels