Skip to content
DeepForgeby svx
All problems
MediumCalculusca-074

Jacobian of Polar Coordinates

Problem

The polar map is (r, theta) -> (x, y) = (r*cos(theta), r*sin(theta)).

Return its 2x2 Jacobian [[dx/dr, dx/dtheta], [dy/dr, dy/dtheta]] = [[cos(theta), -r*sin(theta)], [sin(theta), r*cos(theta)]] evaluated at (r, theta). Theta is in radians.

Hint

Differentiate x and y with respect to r and theta; the determinant equals r.

Test cases

case 1
in: [2,0]
expected: [[1,0],[0,2]]
case 2
in: [1,1.5707963267948966]
expected: [[0,-1],[1,0]]
case 3
in: [3,3.141592653589793]
expected: [[-1,0],[0,-3]]
case 4
in: [0,1]
expected: [[0.5403023058681398,0],[0.8414709848078965,0]]
Starter codePython
def polar_jacobian(r, theta):
    # Return the 2x2 Jacobian
    # Your code here
    pass

4 test cases · run your code against them in the editor