How Long is a Piece of String? Clever Dood Needed!

I have a maths problem.

My program is rendering a sine wave of the form:

y = oy + (ay * SIN(ax * x))

So in ASCII art it looks like :

Code:

`y _`

| / \

| \_/

|______x

Here's my problem. I want to calculate the path length of the wave. Furthermore, I want to calculate the path length traversed from starting point (0, 0) to some point on the x axis.

In otherwords, if we draw the axes on the ground using inches as our dimensions. Then laid out a piece of string in the shape of the sine wave. How long does the string need to be to reach a distince x along the x-axis from the origin?

I believe this problem is solvable with cantenary equations, but my maths is upto scratch with these.

Any ideas?