All problems
Divergence Theorem Check
Problem
The divergence theorem says the outward flux of F across a closed surface equals the integral of div F over the enclosed region.
For F(x, y) = [a*x + b*y, c*x + d*y] and the rectangle [0, w] x [0, h], the divergence is the constant a + d, so the flux is (a + d) * w * h.
Hint
Integrate the constant divergence over the area of the rectangle.
Test cases
case 1
in: [1,0,0,1,1,1]
expected: 2
case 2
in: [2,5,-3,1,3,2]
expected: 18
case 3
in: [0,0,0,0,5,5]
expected: 0
case 4
in: [-1,0,0,1,2,4]
expected: 0
Starter codePython
def divergence_theorem_check(a, b, c, d, w, h):
# Return the flux through the rectangle boundary
# Your code here
pass4 test cases · run your code against them in the editor