All problems
Change of Variables Integral
Problem
Integrate the linear function f(x, y) = a*x + b*y over the parallelogram spanned by the vectors u = (u1, u2) and v = (v1, v2) from the origin.
The substitution (x, y) = s*u + t*v maps the unit square to the parallelogram with Jacobian determinant |u1*v2 - u2*v1|. Since f is linear, the average over the unit square is (f(u) + f(v)) / 2.
Hint
Multiply the average value of f on the unit square by the absolute Jacobian determinant.
Test cases
case 1
in: [1,0,1,0,0,1]
expected: 0.5
case 2
in: [1,0,2,0,0,3]
expected: 6
case 3
in: [1,1,1,1,1,-1]
expected: 2
case 4
in: [0,1,1,0,0,2]
expected: 2
Starter codePython
def change_of_variables(a, b, u1, u2, v1, v2):
# Your code here
pass4 test cases · run your code against them in the editor