Technology Musings

November 14, 2015

General / A General Solution for Line Integrals

JB

Update: I found that this is a standard formula, but it is referred to as an "arc length" formula, not a line integral.  I knew it had to be somewhere, I was just searching the wrong terms.

I was playing around last night, and I came up with, what appears to be, a general solution for line integrals.  I have looked around and I have not found this equation anywhere, although I am certain in must be well-known somewhere.  In any case, I will give it here, because it is definitely not well-known on the Internet.

This is an equation for determining the line integral of y = f(x), where f(x) is a true function of x (i.e. it passes the vertical line test), and is differentiable on the portion of the line where you want to find the length of the line segment.  Most line integrals work by adding in an auxiliary parameter, t, to the equation.  This operates directly on the function itself.

The short version:

To get a line integral from x=a to x=b on y=f(x), we can use the following formula:

Evaluate this from x=a to x=b and you will have the length of the line.  Note, the software I was using gives this as a partial derivative on the inside.  I don't know enough to know if it is only limited to partials or not.

So, if you know the derivate, you can figure out (in theory) the line integral.  Whether or not this actually helps you find a solution to the integral is another story.

Now, how does one arrive at that?

Well, first, remember, that an integral is an infinite sum of infinitesimals.  A curve is simply an infinite sum of tiny, infinitesimal lines.  So, all we need to do is find the length of each line segment and add it up.

How big are our line segments?

Well, if y=f(x), then the line segment is going to be the line between the points x, y and x + dx, y + dy.  The distance formula states that the line length is sqrt( (x1 - x0)^2 + (y1 - y0)^2).  The difference between x + dx and x is simply dx, and the difference between y + dy and y is simply dy.  So, each of our infinitesimal line segments (dL) will be:

dL = sqrt(dx^2 + dy^2)

If we square both sides, we get the following:

dL^2 = dx^2 + dy^2

dL^2 - dx^2 = dy^2

Now we can divide both sides by dx^2 and get:

dL^2/dx^2 - 1 = dy^2/dx^2

dL^2/dx^2 = 1 + dy^2/dx^2

dL^2/dx^2 = 1 + (dy/dx)^2

Now we can square root both sides:

dL/dx = sqrt(1 + (dy/dx)^2)

dL = sqrt(1 + (dy/dx)^2) dx

And this is the final form of our equation.  I tested it out with a few simple integrals (a line and the top half of a circle) and it seems to work as expected.  And, as I said, if you have a line that loops back around, you still need to use the parameterized methods.  But this is an easier way to setup line integrals where f(x) is a true function of x.