Joe Lertola · Mathematical Handbook Big idea 9 of 12

Inside and edge

From the handbook: Several Variables, double integrals §451–458, line integrals and Green's formula §471–475, pages 663–703

A total over a region can be found by adding up tiny squares inside it, or by walking once around its edge.

Vygodsky's Mathematical Handbook
Inside: count the squares whose centers fall in the shape. Drag the corners.
Edge: each step sweeps a triangle from the center of the grid. Orange adds, blue takes away.

Inside

Squares counted
Area of each
Total

Edge

Running total
Exact area

Adding up over an area

Idea 6 added up thin strips under a curve. The same trick works over a whole region of a map: cut it into small squares, work out the quantity on each square, and add them all. With smaller and smaller squares the sum becomes exact. This is the double integral (§451):

∬D f(x, y) dx dy

Read it as “the double integral over the region D of f of x and y, d x d y”. D is the region. f(x, y) is the quantity at each point, for example the height of a terrain (idea 8). dx dy is the area of one tiny square, dx wide and dy tall. Two integral signs because the squares run in two directions.

If f is the height of the ground, the double integral is the volume of earth under the terrain (§452). If f is just 1 everywhere, every square counts as its own area and the total is the area of the region. That simplest case is the left-hand picture: count the squares.

Measuring from the edge

Here is the surprise. You can get the same area without ever looking inside: walk once around the edge, counterclockwise, and at each straight step note the triangle swept out between the step and a fixed center point (the center of the grid). Steps that swing counterclockwise around the center add their triangle; steps that swing back clockwise take theirs away. What is left is exactly the area of the shape. For a polygon with corners (x₁, y₁), (x₂, y₂) and so on, each step from one corner to the next adds

½ (x₁ y₂ − x₂ y₁)

Read it as “one half of: first x times second y, minus second x times first y”. This is the cross product of idea 2 (the signed area of the parallelogram the two corners make with the center), halved to give the triangle.

Worked example. The triangle with corners (1, 1), (5, 1) and (5, 4) has base 4 and height 3, so its area is ½ × 4 × 3 = 6. Walking round it: from (1, 1) to (5, 1) gives ½(1 × 1 − 5 × 1) = −2; from (5, 1) to (5, 4) gives ½(5 × 4 − 5 × 1) = 7.5; from (5, 4) back to (1, 1) gives ½(5 × 1 − 1 × 4) = 0.5. Total: −2 + 7.5 + 0.5 = 6. The first step swings clockwise around the center, so its blue triangle is taken away again.

Green's formula

This is a special case of Green's formula (§474), which says that adding up a certain kind of “swirl” over the inside of a region gives the same answer as adding up a matching quantity along its edge, the line integral (§471). Written out:

∮ P dx + Q dy = ∬ (∂Q/∂x − ∂P/∂y) dx dy

Read it as “walking round the edge and adding P times each step across plus Q times each step up, equals the double integral over the inside of: the east slope of Q minus the north slope of P”. P and Q are any two rules of x and y; the curly ∂ slopes are the partial derivatives of idea 8. The circle on the ∮ means the path closes on itself.

Choose P = −½y and Q = ½x: the inside quantity becomes ½ + ½ = 1, so the right side is the area, and the left side becomes the edge sum above. The book's own example (§473) walks round the triangle with corners (0, 0), (1, 0), (1, 1) adding (x − y²) dx + 2xy dy, and gets ½ + 1 − ⅚ = ⅔. Green's formula says the double integral of 2y + 2y = 4y over the same triangle must also be ⅔, and it is.

This is how a GIS program finds the area of a watershed or a country from nothing but the list of points on its outline. It is also the first taste of a deep pattern in mathematics and physics: what happens inside a region is recorded on its boundary.

Try this

  1. Make the squares smaller and watch the count close in on the exact area. The edge walk gets it exactly, at any size.
  2. Slide the walk back to the start and step it forward. Watch the running total go negative after the first step, then recover.
  3. Press Walk the other way. Every triangle changes sign, and the total comes out as −6: walking clockwise measures the area as negative.
  4. Choose A lake and drag a corner far out, or across the center of the grid. The blue and orange triangles shuffle, but their total always matches the square count.

In the book

Vygodsky, Mathematical Handbook: Higher Mathematics, chapter on functions of several variables.

  • §451–454 The double integral, its meaning as a volume, and its properties. p. 663–667
  • §455–458 Computing a double integral, also in polar coordinates. p. 667–677
  • §471–473 Line integrals, their meaning as work, and the triangle example. p. 695–700
  • §474–475 Green's formula, and when a line integral does not depend on the path (Fig. 467). p. 700–703