PDA

Click to See Complete Forum and Search --> : The length of a sine wave


samwise
Feb 19th, 2001, 03:42 PM
What is the length of a sine wave y = sin(x), from 0 to 2PI?

The standard way of computing it is to intergrate it from 0 to 2PI, as follows

y = sin(x)

Intergrate(sqrt(1 + (dy/dx)^2), 0, 2PI, dx)
(Yes, I'm creating the intergrate function on the fly, but you can see the logic, if you know calculus and parametric equations.)

This leads to the following:
Intergrate(sqrt(1 + (cos(x))^2), 0, 2PI, dx)
Now, I'm stuck. where can I go from here?

And don't make the mistake of saying
1 + (cos(x))^2 = sin(x)^2

The correct substitution for that is
1 - (cos(x))^2 = sin(x)^2

The one thing I can use (I guess) is symmetry.
I know the length of a cosine wave is the same as a sine wave. therefore
Len(sine wave) = Len(cos wave),
or
Intergrate(sqrt(1 + (cos(x))^2), 0, 2PI, dx) =
Intergrate(sqrt(1 + (sin(x))^2), 0, 2PI, dx)

where do I go from here?

If I can't directly solve it, how do I approximate it?

What value does it approach?

(just doing some recreational math)

Samwise Galenorn
sam@galenorn.com

Guv
Feb 20th, 2001, 03:42 PM
I hunted through some tables of known integrals and could not find anything.

The integral of a function is equal to the area under the curve represented by the function.

You can approximate the area by adding up the areas of a lot of little trapezoids. The more trapesoids, the more accurate the approximation. For 1000 trapezoids the formulae would be the following.

The height of each would be DeltaX = 2*Pi/1000
Length1 would be sqr(1 + cos(x)^2)
Length2 would be Sqr(1 + cos(x + DeltaX)^2)
Trapezoid area = DeltaX*(length1 + length2) / 2

Write a 1000-step loop starting with x = 0 and NextX = X + DeltaX. Compute an area in each loop and add them up.

My guess is that 1000 steps would give an accurate approximation. You could try 500, 1000, and 2000 steps, compare the results, and get a fair idea of how accurate the approximations are. My guess is that there would not be much difference between 1000 and 2000 steps, indicating good accuracy.

If you are fanatic about CPU time, you can use special case code for cosine and square root, since the value of X changes so little for each step. Note also that Length1 for next step equals length2 from last step.

When I used numerical integration and numerical methods for solving differential equations years ago, I took advantage of special case formulae to save time. On prehistoric machines which took milliseconds to add, you had to worry about CPU time.

PaulLewis
Feb 20th, 2001, 04:32 PM
I actually came looking for my own answers, but your question was interesting.

I didn't realise how to go about working out the length of a sine wave because my rather literal interpretation re: length of any line doesn't involve integration.

So I assume there is much more to it than what I am imagining...

Be that as it may, sometimes even silly ideas help at some level, so my idea is that the length of the line described by the curve y=sin(x) form 0 to 2pi is 2pi.

My theory is that if I had a piece of string excatly 20 * pi cm long, and placed it over a sine wave of y=10 sin(x), that it would match perfectly... Furthermore the same piece of string would fit circle of radius 10cm also.

1) I haven't tried this so I'm probably waaaay off base
2) Length of a sine wave might be something else altogether which my limited maths background wouldn't have subjected me to :)

Anyhow - I'm off to look for my answer

Cheers
Paul Lewis

Guv
Feb 20th, 2001, 10:00 PM
Paul Lewis: y = sin(x) is called a sine wave because it looks like a wave. While x goes from zero to 2*Pi, the sine wave (y) starts at zero rises smoothly to one, descends through zero to minus one, and rises to zero. As x increases, y traces out the same curve again and again.

Since a straight line is the shortest distance between two points, 2*Pi must be the shortest distance from zero ro 2*Pi on the X-Axis. The sine wave between the same two points must be longer: Obviously much longer.

An integral is the sum of an infinite number of infinitesimally small amounts (Excuse the mathematical slang, or shorthand). If the infinitesimal amounts are lengths, the integral is a length. If the infinitesimal amounts are areas, the integral is an area.

PaulLewis
Feb 21st, 2001, 01:17 AM
Hehe

Well it seems pretty simple when you put it like that..Thanks for the explanation...

I'll go back to the drawing board.

samwise
Feb 21st, 2001, 03:56 PM
The length of a curve, from a to b is by using the following :

let the function be y = f(x),
range from a to b

therefore, the len from a to be is

Intergrate(sqrt(1 + (dy/dx)^2), a, b, dx)

Yes, I could come up with a computer solution using Rieman approximations with trapezoids. I wanted some sort of solution with a distinct summation, such that when the limit of the intergration goes to infinity, the solution converges to a distict value.

Samwise 'RecreationalMathNerd' Galenorn
sam@galenorn.com

samwise
Feb 21st, 2001, 03:57 PM
Unfortunately, I didn't study this too much in my math studies (damn, my Taylor approximation knowledge!!!)

Samwise Galenorn
sam@galenorn.com

Guv
Feb 21st, 2001, 06:33 PM
SamWise: There does not seem to be an analytical solution. I checked with a table of known integrals, and did not find anything.

On rare occasions, I have seen an analytical solution when there was nothing in the table of integrals I use. In general, I would not bet on it. This integrand is so simple looking that I would expect to see it in the table if there was an analytical solution.

There might be some tricky substitution leading to an easier integrand, but I doubt it.