A928 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

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 𝐅=(−y3,x3), which circles the origin more strongly farther out.
  • The readout is its circulation around a circle of radius R, ∮𝐅⋅d𝐥=3πR42, which Green's theorem gives as ∬3(x2+y2)dA.
  • Double R and the circulation grows sixteen times: the integrand 3r2 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?

Name it

A line integral as a sum

Sample the path at points 𝐫0,𝐫1,…,𝐫n. Then

∫C𝐅⋅d𝐥≈∑k𝐅(𝐫k+𝐫k+12)⋅(𝐫k+1−𝐫k)

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 𝐫′(t)Δt.

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

∮(Pdx+Qdy)=∬(∂Q∂x−∂P∂y)dA. With P=−y2, Q=x2, the right side is the area, so a closed polygon's area comes from its corners alone:

A=12∑k(xkyk+1−xk+1yk)

(the shoelace formula), positive when the corners run counterclockwise.

Worked example

Find the work of 𝐅=(x2,xy) from (0,0) to (1,2) along the straight line and along the path that goes right, then up.

Show the solution
  1. Straight line. 𝐫=(t,2t) gives W=∫015t2dt=53=1.667
  2. Right along the x axis. Here 𝐅⋅d𝐥=x2dx, giving 13.
  3. Then up the line x=1. Here 𝐅⋅d𝐥=1⋅ydy, giving 222=2.
  4. Total for the bent path. 13+2=2.333
  5. Why they differ. This field is not conservative. Its curl is ∂(xy)∂x−∂(x2)∂y=y

Answer the straight line gives 1.667 and the right-then-up path gives 2.333.

Worked example

The field 𝐄=(2xy,x2) V/m. What is the voltage between (0,0) and (2,1) m?

Show the solution
  1. Check the curl. 2x−2x=0 so it's conservative.
  2. Find the potential. 𝐄=∇(x2y), that is, V=−x2y.
  3. Voltage. V(2,1)−V(0,0)=−4V The point (2,1) is 4 V below the origin.
  4. Check along a path. Along the x axis 𝐄⋅d𝐥=0; then up x=2, ∫014dy=4V of work per coulomb, so the potential falls by 4 V.

Answer the point (2,1) m is 4 V below the origin: V(2,1)−V(0,0)=−4 V.

Check

What is the circulation of 𝐅=(−y3,x3) counterclockwise around a circle of radius 1?

Check

What does the shoelace formula give for the triangle (0,0), (2,0), (2,1)?

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 𝐅=(x2,xy) along 1001 points of the straight line from (0,0) to (1,2).

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 𝐅=(x2,xy) from (0,0) to (1,2) 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 𝐅=(−y3,x3) on the unit circle: compute the circulation with 20 001 points and set circ, and set area_integral to ∬3(x2+y2)dA 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 (0,0), (4,0), (5,3), (2,5), (−1,3) 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 𝐄=(2xy,x2) V/m, use your line_integral (in the starter) to integrate from (0,0) to (2,1) along a straight line and along a parabola y=x2/4, and set V1 and V2 to the voltage −∫𝐄⋅d𝐥 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?

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.