Why This Matters
So far you have integrated over intervals, rectangles, and solid regions. But what if you need to integrate along a curved path or over a curved surface? A line integral sums a quantity along a curve. If you integrate a vector field along a path, the result is the work integral -- the total work done by a force as an object moves along that path.
A surface integral extends this idea to two dimensions: it sums a quantity over a curved surface in 3D space. Surface integrals compute the total flux of a vector field through a membrane, the total mass of a thin shell, or the area of a parametric surface. These integrals are the building blocks for the great theorems of vector calculus (Green, Stokes, Divergence) and appear throughout physics whenever quantities flow through boundaries.
Define Terms
Visual Model
The full process at a glance. Click Start tour to walk through each step.
Line integrals sum along curves (computing work or arc-length quantities). Surface integrals sum over surfaces (computing flux or area).
Code Example
// Line integral: approximate work done by F along a curve
// F(x, y) = (y, -x), curve: upper semicircle from (1,0) to (-1,0)
// r(t) = (cos(t), sin(t)), t in [0, pi]
function F(x, y) {
return [y, -x];
}
// Parameterized curve
function r(t) {
return [Math.cos(t), Math.sin(t)];
}
function rPrime(t) {
return [-Math.sin(t), Math.cos(t)];
}
// Approximate line integral using Riemann sum
function lineIntegral(fieldFn, rFn, rPrimeFn, a, b, n) {
const dt = (b - a) / n;
let sum = 0;
for (let i = 0; i < n; i++) {
const t = a + (i + 0.5) * dt;
const pos = rFn(t);
const vel = rPrimeFn(t);
const field = fieldFn(pos[0], pos[1]);
// Dot product: F . r-prime
sum += (field[0] * vel[0] + field[1] * vel[1]) * dt;
}
return sum;
}
// F = (y, -x) on unit circle: F . r-prime = sin(t)*(-sin(t)) + (-cos(t))*cos(t) = -1
// Integral from 0 to pi of -1 dt = -pi
console.log("Work (n=100):", lineIntegral(F, r, rPrime, 0, Math.PI, 100).toFixed(6));
console.log("Work (n=10000):", lineIntegral(F, r, rPrime, 0, Math.PI, 10000).toFixed(6));
console.log("Exact: -pi =", (-Math.PI).toFixed(6));
// Scalar line integral: arc length of semicircle
function scalarLineIntegral(fn, rFn, rPrimeFn, a, b, n) {
const dt = (b - a) / n;
let sum = 0;
for (let i = 0; i < n; i++) {
const t = a + (i + 0.5) * dt;
const pos = rFn(t);
const vel = rPrimeFn(t);
const speed = Math.sqrt(vel[0] * vel[0] + vel[1] * vel[1]);
sum += fn(pos[0], pos[1]) * speed * dt;
}
return sum;
}
// f = 1, arc length of semicircle = pi
console.log("Arc length:", scalarLineIntegral((x,y) => 1, r, rPrime, 0, Math.PI, 10000).toFixed(6));
console.log("Exact: pi =", Math.PI.toFixed(6));Interactive Experiment
Try these exercises:
- Compute the work integral of F = (1, 0) (constant rightward force) along the straight path from (0, 0) to (3, 0). You should get 3.
- Compute the line integral of F = (y, x) around the full unit circle. Since this field is conservative (F = grad(xy)), the integral should be zero.
- Compute the arc length of one full turn of the helix r(t) = (cos(t), sin(t), t) for t in [0, 2*pi]. Hint: the speed is constant.
- Change the number of sample points from 10 to 100 to 10000. How does the approximation error decrease?
- Try a non-smooth curve (e.g., a triangle path) by breaking it into segments and summing the line integrals over each segment.
Quick Quiz
Coding Challenge
Write a function called `approxLineIntegral` that takes n (number of subdivisions) and approximates the work integral of the vector field F(x,y) = (x*y, x^2) along the parabolic path r(t) = (t, t^2) from t = 0 to t = 1. Use the midpoint rule with n subdivisions. Return the result rounded to 4 decimal places as a string. Hint: r-prime(t) = (1, 2t) and F.r-prime = x*y*1 + x^2*2t.
Real-World Usage
Line and surface integrals model physical processes involving flow and boundaries:
- Physics (work and energy): The work done by a force on a particle moving along a path is a line integral. This is how physicists compute kinetic energy changes in variable force fields.
- Electromagnetism: Faraday law says the voltage around a loop equals the negative rate of change of magnetic flux through the loop. Both quantities are line and surface integrals.
- Fluid mechanics: The flux of a velocity field through a surface gives the volumetric flow rate. Engineers use this to design pipes, nozzles, and ventilation systems.
- Computer graphics: Rendering techniques compute the integral of incoming light over the visible hemisphere at each surface point (the rendering equation is a surface integral).
- Circulation in meteorology: The circulation around a weather system is a line integral of wind velocity. It quantifies the rotational strength of hurricanes and cyclones.