All problems
Stokes Circulation Numeric
Problem
Compute the counterclockwise circulation of F = [-c*y, c*x] around the boundary of the unit square [0, 1]^2.
Parameterize each edge and apply the midpoint rule with n segments per edge. Since the field is linear the midpoint rule is exact and the circulation equals 2c, matching the curl integral.
Hint
Only the right and top edges contribute; the field is tangent to the bottom edge and zero along the left one.
Test cases
case 1
in: [1,4]
expected: 2
case 2
in: [-2,10]
expected: -4
case 3
in: [0,5]
expected: 0
case 4
in: [3,1]
expected: 6
Starter codePython
def stokes_circulation(c, n):
# Your code here
pass4 test cases · run your code against them in the editor