A9 · Lesson 28 · Lab: line integrals
Work, circulation and Green's theorem by computer
Lessons 23 to 27 integrated fields along paths and around loops. In code, a path is a list of points, and a line integral is a sum of along it. In this lab you'll write that sum, use it to show that one field's work depends on the path while another's doesn't, check Green's theorem on a circle, compute a polygon's area from its boundary alone, and find the voltage between two points of an electric field by integrating along two different routes.
- The field is , which circles the origin more strongly farther out.
- The readout is its circulation around a circle of radius , , which Green's theorem gives as .
- Double and the circulation grows sixteen times: the integrand grows and so does the area.
Predict
A field does work 5 J moving a charge from A to B along one path, and 3 J along another. What can you conclude?
It isn't conservative. Going out along the first path and back along the second gives a closed loop with work J, a nonzero circulation. For a conservative field, like an electrostatic one, every loop gives zero and every path gives the same work. A changing magnetic field makes the electric field non-conservative, which is how a transformer works.
Name it
A line integral as a sum
Sample the path at points . Then
Evaluating at each segment's midpoint makes the error proportional to the square of the segment length. For a parametrized path, the same sum can be written with .
Testing for conservative fields
A field is conservative if its work is the same along every path between two points; equivalently, its circulation around every loop is zero; in a region without holes, equivalently, . Numerically: compare two different paths, or compute the curl on a grid.
Green's theorem and areas
. With , , the right side is the area, so a closed polygon's area comes from its corners alone:
(the shoelace formula), positive when the corners run counterclockwise.
Worked example
Find the work of from to along the straight line and along the path that goes right, then up.
Show the solution
- Straight line. gives
- Right along the axis. Here , giving .
- Then up the line . Here , giving .
- Total for the bent path.
- Why they differ. This field is not conservative. Its curl is
Answer the straight line gives 1.667 and the right-then-up path gives 2.333.
Worked example
The field V/m. What is the voltage between and m?
Show the solution
- Check the curl. so it's conservative.
- Find the potential. , that is, .
- Voltage. The point is 4 V below the origin.
- Check along a path. Along the axis ; then up , of work per coulomb, so the potential falls by 4 V.
Answer the point m is 4 V below the origin: V.
Check
What is the circulation of counterclockwise around a circle of radius 1?
Check
What does the shoelace formula give for the triangle , , ?
Check
Write line_integral(F, pts) for a field F(x, y) returning a NumPy pair and a path given as an array of points, using midpoints. Set W for along 1001 points of the straight line from to .
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Using your line_integral (in the starter), compute the work of from to along "right, then up" (two straight legs of 1001 points each). Set W2 and diff = W2 - 5/3.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Check Green's theorem for on the unit circle: compute the circulation with 20 001 points and set circ, and set area_integral to evaluated in closed form.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write shoelace(xs, ys) returning a polygon's signed area. Set A for the pentagon with corners , , , , in order.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
For V/m, use your line_integral (in the starter) to integrate from to along a straight line and along a parabola , and set V1 and V2 to the voltage along each.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why is the shoelace formula a special case of Green's theorem?
Green's theorem turns a circulation around a closed boundary into an integral of over the inside. Choosing and makes that integrand 1, so the double integral is the area, and the area equals . On a polygon the boundary is straight segments, and along each segment the integral works out exactly to . Adding them gives the shoelace formula, which is why it needs only the corners and why its sign records the direction you went round.
Practice
Keep practicing
4 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.