# Estimating the arc length of a sine wave using this polynomial formula?

I need to calculate the arc length of a half period of a sine wave with a given frequency and amplitude.

I found this article which summarizes a polynomial method for getting a very close approximation:

http://edspi31415.blogspot.com/2012/05/arc-length-of-sinx-curve-approximation.html

He states:

We have been looking to find the arc length of the curve $$y = a sin x$$ from $$x = 0$$ to $$x = π$$.

The exact value is:

$$π ∫ √ (1 + a^2 cos^2 x ) dx$$

$$0$$

However, a good estimate can be found (to 2-3 decimal places) with the polynomial:

$$y = .0081196317102889 x^4 - .11577326164517 x^3 + .63914882375794 x^2 + .2071162669684 x + 3.0881429428239$$

I'm having trouble understanding how that polynomial works though. Arc length of the sine wave will vary both with amplitude and frequency of the sine wave, right? I don't see a way to accommodate for that.

Let's say I have a simple equation of:

$$y = a * sin (\frac{π x}{c})$$

As shown here:

https://www.desmos.com/calculator/gshaw6pqar

Could this polynomial give me the arc length say from $$x=0$$ to $$x=c$$ on that graph? If so, how do I implement it?

Alternatively, are there any good or easy to implement other polynomial solutions for this problem?

• You can get the proper font and spacing for $\cos$ and $\sin$ using \cos and \sin. For operators that don't have a command of their own, you can use \operatorname{name}. Apr 25, 2020 at 4:59
• Why did you delete this related question? I was in the process of answering it. Apr 25, 2020 at 5:13
• I'm sorry. I undeleted it if you can still post your answer and haven't lost it. I thought it was redundant since I think I just needed better coefficients as noted below. I think I am just looking for a set of coefficients now where the fifth polynomial coefficient equals pi, then it will be valid for all amplitudes.
– mike
Apr 25, 2020 at 5:16

Too long for a comment.

@Parcly Taxel gave the good answers and, in particular, pointed out that the polynomial is in $$a$$ and not in $$x$$.

The small problem I see here is that the choice of the data points based on which the polynomial regression is made is totally arbitrary (thst is to say that user smaller or larger stepsize will affect the result. We can get rid of this using in fact the norm of the system.

The exact arclength is given by $$L=\int_0^\pi \sqrt{1+a^2 \cos ^2(x)}\,dx=2 \sqrt{a^2+1} E\left(\frac{a^2}{a^2+1}\right)$$ and we want to approximate it by the model $$L'=\sum_{i=1}^5 b_i\,a^{5-i}$$ So consider $$\Phi(b_1,b_2,b_3,b_4,b_5)=\int_0^5 (L'-L)^2\, da$$ (for sure, changing the range will change the results) and numerically minimize $$\Phi(b_1,b_2,b_3,b_4,b_5)$$ with respect to its parameters. This procedure is equivalent to the curve fit on the basis of an infinite number of data points.

The final results would be $$\{0.00933896279029,-0.128748093746, 0.68584815405609, 0.142654927513, 3.11458534187676\}$$

Edit

In comments, you asked for the same work forcing the constant to be equal to $$\pi$$. For the same conditions as before $$(0 \leq a \leq 5)$$, the coefficients are $$\{ 0.0104354807025,-0.14091929319588, 0.73142257586132, 0.07768768253114\}$$ and the value of the norm is $$0.00045$$ instead of $$0.00031$$. Not a big loss.

Update

We can make a quite good approximation of $$L$$ using Padé approximants built at $$a=0$$. They will write $$L=2 \sqrt{a^2+1} E\left(\frac{a^2}{a^2+1}\right)\sim\pi\,\frac{1+\sum _{i=1}^n b_i\,a^{2 i} } {1+\sum _{i=1}^n c_i\,a^{2 i} }$$ and I shall write the coefficients as $$b_i=\frac {b^{(0)}_i} {b^{(1)}_i}$$ and $$c_i=\frac {c^{(0)}_i} {c^{(1)}_i}$$ to provide the exact numbers. For $$n=6$$, they are $$\left( \begin{array}{ccc} n &{b^{(0)}_i} &{b^{(1)}_i} \\ 1 & 978715518761734721 & 340266845202118768 \\ 2 & 17217154294207083315 & 5444269523233900288 \\ 3 & 2259182768960973723 & 1361067380808475072 \\ 4 & 147017417917716730895 & 348433249486969618432 \\ 5 & 1025154552798223543815 & 22299727967166055579648 \\ 6 & 514701376255563496705 & 356795647474656889274368 \end{array} \right)$$ $$\left( \begin{array}{ccc} n &{c^{(0)}_i} &{c^{(1)}_i} \\ 1 & 893648807461205029 & 340266845202118768 \\ 2 & 13897759198263852275 & 5444269523233900288 \\ 3 & 765774311593521685 & 680533690404237536 \\ 4 & 76540276098711585485 & 348433249486969618432 \\ 5 & 340415228454088445827 & 22299727967166055579648 \\ 6 & 58924683873615813721 & 356795647474656889274368 \end{array} \right)$$ and they match extremely well at least up to $$a=3$$. For sure, we could improve adding more terms.

Another way would be to write $$L=2 \sqrt{a^2+1} E\left(\frac{a^2}{a^2+1}\right)=\pi \,\sqrt{a^2+1}\, \sum_{n=0}^\infty \frac{ ((2 n)!)^2 }{2^{4 n}\,(1-2 n)\ (n!)^4}\left(\frac{a^2}{a^2+1}\right)^n$$

• Thanks Claude. I don't have the math skill to reproduce how you worked out those new coefficients exactly, but they definitely perform a bit better at lower amplitude. Your coefficients allow me to go down to an amplitude of about >=0.12 before it gives impossible results. Is it possible to design coefficients that will go down to even lower amplitude? Thanks.
– mike
Apr 25, 2020 at 4:48
• @ Claude Leibovici , what I suppose I am looking for would be a set of coefficients where the fifth coefficient is equal to pi. Then no matter how low the amplitude, it will always give a minimum value that makes sense. Could you offer me any set of coefficients that might work well where the fifth coeffecient equals pi? Thanks again.
– mike
Apr 25, 2020 at 5:10
• @mike. you cannot concieve how much this request is nice to me ! I shall do it for you. I shall make both and edit my answer. Let me one hour. Cheers. Apr 25, 2020 at 5:49
• @mike. Already done ! Are you sure that you want such a large range for $a$ ? Apr 25, 2020 at 5:50
• You're amazing. That is so incredibly helpful. Yes, I need to be able to calculate the arc lengths of the sine wave all the way smoothly down to an amplitude of 0, so that works brilliantly now. If this is not too hard for you and it might provide different or more accurate results to restrict the range, what would also be the coefficients for an ideal range of a from 0 to 1? If it's a bother don't worry, I'm sure the 0 to 5 amplitude range coefficients you provided will work well enough. Thanks again. I'm very grateful. You made my day.
– mike
Apr 25, 2020 at 5:55

For $$a\sin x$$, since the arc length is always taken between the same endpoints, it depends on only one variable and we can apply one-dimensional regression to it, which is what the blog post did. There, the explanation earlier up reads

What I was looking for was which regression had the best coefficient of determination ($$R^2$$). In general, the closer $$R^2$$ is to $$1$$, the better the fit.

I ended up choosing the quartic regression (4th degree polynomial) with $$R^2\approx0.9999919$$.

So the resulting approximation is just a quartic fit to the data. It would have better been written with $$a$$ replacing $$x$$ and $$L$$ replacing $$y$$.

To transform your problem into the $$a\sin x$$ problem, note that uniformly scaling the Euclidean plane scales all arc lengths proportionally. Thus the arc length of $$a\sin\frac{\pi x}c$$ over $$[0,c]$$ is the arc length of $$\frac{a\pi}c\sin x$$ over $$[0,\pi]$$ multiplied by $$\frac c\pi$$.

• Thanks Parcly. So you're saying the equation he gave was: $L=0.0081196317102889a^4−0.11577326164517a^3+0.63914882375794a^2+0.2071162669684a+3.0881429428239$, where $L$ is length and $a$ is amplitude. Is that correct? And this equation gives the arc length of half a period of a sin wave over [0,π]. So to get the arc length of a half period over [0,c], I just take the solution of that polynomial and multiply by $\frac{c}{π}$? If so, that's fantastic and very easy for me to use! Thanks.
– mike
Apr 25, 2020 at 1:30
• @mike Yes, you are correct on that regard. Apr 25, 2020 at 1:32