Skip to content
DeepForgeby svx
All problems
EasyCalculusca-146

Spherical Jacobian Factor

Problem

In spherical coordinates (r, phi, theta) with phi measured from the positive z-axis, the volume element is dV = r^2 * sin(phi) dr dphi dtheta.

Given r and the polar angle phi in radians, return the Jacobian factor r^2 * sin(phi).

Hint

The factor vanishes at the poles where sin(phi) = 0.

Test cases

case 1
in: [2,1.5707963267948966]
expected: 4
case 2
in: [1,0]
expected: 0
case 3
in: [3,0.5235987755982988]
expected: 4.499999999999999
case 4
in: [0,1]
expected: 0
Starter codePython
def spherical_jacobian(r, phi):
    # Your code here
    pass

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