All problems
Surface Area of a Spherical Cap
Problem
The surface area element of a sphere of radius R is R^2 * sin(phi) dphi dtheta, with phi the polar angle.
Integrating from the pole to phi_max gives the area of a spherical cap: 2 * pi * R^2 * (1 - cos(phi_max)). Given the radius and phi_max in radians, return the cap area.
Hint
A hemisphere is half the sphere area, matching the formula at phi_max = pi / 2.
Test cases
case 1
in: [1,1.5707963267948966]
expected: 6.283185307179585
case 2
in: [1,0]
expected: 0
case 3
in: [2,3.141592653589793]
expected: 50.26548245743669
case 4
in: [1,1.0471975511965976]
expected: 3.1415926535897922
Starter codePython
def spherical_cap_area(radius, phi_max):
# Your code here
pass4 test cases · run your code against them in the editor