All problems
Conservative Potential Value
Problem
The field F(x, y) = [a*x + b*y, b*x + c*y] is conservative because its Jacobian is symmetric.
Find the potential phi with phi(0, 0) = 0 and return phi(x, y) = 0.5*a*x^2 + b*x*y + 0.5*c*y^2.
Hint
Integrate the first component with respect to x, then match the second component.
Test cases
case 1
in: [2,0,2,1,1]
expected: 2
case 2
in: [4,1,2,2,3]
expected: 23
case 3
in: [0,0,0,5,5]
expected: 0
case 4
in: [-2,3,1,1,-1]
expected: -3.5
Starter codePython
def potential_value(a, b, c, x, y):
# Your code here
pass4 test cases · run your code against them in the editor