Numerical Integration of Line Integrals

Here you can calculate line integrals over curves in the xy plane for scalar fields and for vector fields .
The curves can be created for polylines using a list of points to be connected or, for curved curve segments, by providing parametric equations.






Curve points (xi/yi) can be edited as a table or moved with the mouse.

Curvilinear segments can be included by providing the respective curve in parameter form as x(t) and y(t).
For the curve parameter t, the start and end of the respective curve segment are then specified in the 3rd column with two entries.
The curve defined via the parameter representation in the first two columns is then run through starting at t=t1 up to t=t2.
When choosing the order of the two t values, it is important to ensure that all curve segments for t1->t2 are run through with a common orientation, pointing from the starting point to the end point of the entire curve.

Line integrals of scalar fields and of vector fields are distinguished here as follows:

Line integrals of scalar fields
 ∫ f(x,y) ds
C
One function f(x,y) must be provided.

Line integrals of vector fields
 ∫ [ f(x,y) dx + g(x,y) dy ]
C
or formulated using the scalar product
 ∫ { f(x,y), g(x,y) }·{ dx, dy }
C
Two functions f(x,y) and g(x,y) must be provided, separated by a semicolon (;).

The two functions of the integrand, designated here as f(x,y) and g(x,y), can of course also depend on only one of the two variables or be constant.

Parameter representation of a curve

You need this in case that the curve (or a partial curve) of the line integral is curved.

In the simplest case, there is already information for the curve
for x and y depending on a parameter, such as
x(φ) = 3*cos(φ)
y(φ) = 4*sin(φ)

you just have to rename the parameter to t, i.e.
x = 3*cos(t)
y = 4*sin(t).

If for the curve an explicit function representation as
y = f(x)
is given, then you have to replace the independent variable, here x, through t. For example for

y = 2*x - sin(x)
we set
x = t
y = 2*t - sin(t)

or
x = cosh(y)
leeds to
x = cosh(t)
y = t

In the case of an implicit function representation you have to try to solve for one of the two variables.
You can then proceed as already described.

Application examples

 ∫ 1 ds calculates the length of curve C.
C
 ∫ x ds/L calculates the x coordinate of the center of gravity of curve C with length L.
C
 ∫ y ds/L calculates the y coordinate of the center of gravity of curve C with length L.
C
 ∮ [ -y/2 dx + x/2 dy ] calculates the area of an area that is surrounded by the closed curve C to the left.
C
 ∫ [ P(x,y) dx + Q(x,y) dy ] is the work that occurs in the force field {P(x,y), Q(x,y)} when the point of force application is moved along C.
C
 ∮ [ P(x,y) dx + Q(x,y) dy ] calculates the circulation of field {P(x,y), Q(x,y)} for the closed curve C.
C

General information about line integrals

Line integrals of scalar fields are independent of the orientation in which the curve is traversed for the calculation.
For line integrals of vector fields, the sign of the result changes when the orientation of the curve is changed.

With line integrals of vector fields there is also the phenomenon of path independence.
For vector fields that can be represented as a gradient of a scalar potential function,
the result of the line integral is independent of the path or curve that leads from any starting point to any end point.
An integral over a closed curve then necessarily returns 0, because the shortest curve between the starting point and end point has the length 0.

A test for path independence of the line integral for a field f(x,y)={ fx(x,y), fy(x,y) } is given with the integrability condition:

∂fx/∂y = ∂fy/∂x.

If this condition is fulfilled, there is a potential function U(x,y) for which the following applies:

∂U(x,y)/∂x = fx(x,y) and
∂U(x,y)/∂y = fy(x,y).

The line integral of vector fields now can be determined more easily,
by integrating fx with respect to x and fy with respect to y and then combining the results to form the potential function U(x,y).
The potential difference between the end point E and the starting point S of the curve is then the result of the line integral:

 ∫ f dx = U(xE, yE) - U(xS, yS) .
C

Calculation example for path independence

The line integral of the second kind for the vector field
f(x,y) = { x2+y, y3+x }
is path independent because the integrability condition is satisfied:

∂fx/∂y = ∂(x2+y)/∂y = 1 and
∂fy/∂x = ∂(y3+x)/∂x = 1.

So there is a potential function U(x,y) with
∂U(x,y)/∂x = fx(x,y) and
∂U(x,y)/∂y = fy(x,y).

In reversing the derivation with respect to x you need an unknown functional component g(y) and analogously in reversing the derivation with respect to y you need an unknown functional component h(x):

U(x,y) = ∫ fx(x,y) dx + g(y) = x3/3 + xy + g(y)
U(x,y) = ∫ fy(x,y) dy + h(x) = y4/4 + xy + h(x)

The scalar function you are looking for is created as a summary of the results of the two integrals:
U(x,y) = xy + x3/3 + y4/4 + C1, C1.

The line integral
 ∫ [ (x2+y) dx + (y3+x) dy ]
C
satisfies the integrability condition, so it is path independent.

For any curve C from point S(0/0) to point E(1/2), the difference of the potential function U(x,y) gives evaluated at the two points:

U(1,2) - U(0,0) = 2 + 13/3 + 24/4 = 2 + 1/3 + 4 = 19/3.

To calculate the line integral directly, we take the direct connecting line of points S and E, y = 2x with 0 ≤ x ≤ 1.
This results in dy/dx = 2 and therefore dy = 2dx. If you insert this into the line integral, you get:
∫ ( (x2 + 2x)·1 + (8x3+x)·2) dx = ∫ 16 x3 + x2 + 4x dx = 4x4 + x3/3 + 2x + C.

If you evaluate the antiderivative function at x=1 and at x=0, you again get the difference as 19/3.


Calculating the potential difference between points S(0/0) and point E(3/0), one obtains:
U(3,0) - U(0,0) = 33/3 = 9.

The direct connecting line between S(0/0) and E(3/0) is y = 0. dy = 0 follows and the line integral becomes:
∫ [ x2 dx + x dy ] = ∫ x2 dx = x3/3 + C.

If you evaluate the antiderivative function at x=3 and at x=0, you again get the difference as 33/3.


more JavaScript applications