In this post we look at an algorithm to compute arc lengths of a differentiable curve. First lets recall the definitions:
Let be a the curve parametrized by .
The thing that is niceĀ aboutĀ arc lengths is that they are integrals and behave well even when our curve fails to be differentiable at places. The thing that is not nice (computationally) is that for general polynomial curves this integral may not have closed form expression. Try this in wolfram alpha for example:
Integrate[Sqrt[1 + x + 2 x^2 + x^5], x]
We thus have to resort to numerical techniques, such as the Gaussian quadrature to get an answer. Gaussian quadrature is a remarkably effective tool too(esp for smooth functions) and whats more the convergence is fast for all practical purposes( error ~ for term evaluation where is what is being integrated). This does not mean we should stop playing with this and see where it can take us. The complexity comes from the square root right, lets get rid of it and start playing.
Lets write
This is a tractable problem and definitely can be evaluated for polynomial curves but it is way off the result. Lets us see the connection between the two
This depends purely on the derivatives and there appears no direct way to retrieve the arc length from this. Lets try to bringing in a friend of of to see a better connection. Define and differentiate.
or
Since we have come this far, let take this as far as it gets us. Rewrite the above with on lhs
or
or
Note that lhs is ready for integration but rhs is not. If we can express (in the rhs) as a power series in terms of then integrating rhs is also easily done. We can worry about the fact that power series exists later(see, we are in real world) lets follow this trail anyway.
Lets write
then
Our job is to find such that both sides match. At this point we have to break off and do a hand calculation which reveals the following (or use as CAS tool to get these identities as you prefer)
You can see additional terms here. Calculated using
We can retrieve the arc length from this by using the identity
.
or
But wait, there is another way we can retrieve without involving additional integrals:
or
Lets unit test this with a basic function:
parametrized by
The closed form of the arc length of this parabola is:
(courtesy wolfram alpha) and this has the series expansion
Using our calculations we get,
from which
which has the power series expansion:
if one uses the expansion that does not involve integrals we get
which has error an order of magnitude larger than the previous expansion.
Parametrization
Now, having come this far let us also look to see if we can parameterize the curve using arc length.
Given arc length s, our task is to find such that
Using our series expansion, we may write
which suggests fixed point algorithm using where
this would converge provided which would be true if
or
The scheme will hence get us to the fixed point provided stays away from zero.