All problems
Divergence of Curl Identity Check
Problem
The identity div(curl F) = 0 holds for smooth fields. Verify it numerically for F = [a*y*z^2, b*z*x^2, c*x*y^2].
Compute the curl with central differences (step h = 1e-5), then take the central-difference divergence of that curl. The return value is the residual, which should be near 0.0.
Hint
Two applications of central differences should cancel to within round-off.
Test cases
case 1
in: [1,1,1,1,2,3]
expected: 0
case 2
in: [2,-3,4,-1,0.5,2]
expected: 0
case 3
in: [0,1,0,3,3,3]
expected: 0
case 4
in: [-1,2,-2,0,1,-1]
expected: 0
Starter codePython
def div_of_curl_check(a, b, c, x, y, z, h=1e-5):
# Your code here
pass4 test cases · run your code against them in the editor