Lesson 13 of 18

Polar Double Integral

Integration in Polar Coordinates

Some regions are naturally described in polar coordinates (r,θ)(r, \theta) rather than Cartesian (x,y)(x, y).

The Polar Jacobian

When converting to polar coordinates x=rcos(θ)x = r\cos(\theta), y=rsin(θ)y = r\sin(\theta), the area element becomes:

dA=rdrdθdA = r\, dr\, d\theta

The extra rr factor (the Jacobian) accounts for the stretching near the origin.

The Formula

Rf(x,y)dA=abr0r1f(rcosθ,rsinθ)rdrdθ\iint_R f(x,y)\, dA = \int_a^b \int_{r_0}^{r_1} f(r\cos\theta,\, r\sin\theta) \cdot r\, dr\, d\theta

Midpoint Rule in Polar Coordinates

Divide [r0,r1][r_0, r_1] into nrn_r strips and [a,b][a, b] into nθn_\theta angular sectors:

ijf(ricosθj,risinθj)riΔrΔθ\approx \sum_i \sum_j f(r_i \cos\theta_j,\, r_i \sin\theta_j) \cdot r_i \cdot \Delta r \cdot \Delta\theta

Classic Example: Area of a Disk

For a disk of radius RR:

02π0Rrdrdθ=2πR22=πR2\int_0^{2\pi} \int_0^R r\, dr\, d\theta = 2\pi \cdot \frac{R^2}{2} = \pi R^2 \checkmark

Applications

  • Area of circles, sectors, rings
  • Volume of cylinders and cones
  • Integrals with x2+y2x^2 + y^2 in them (naturally round)

Your Task

Implement double polar_double_integral(double (*f)(double, double), double r0, double r1, double a, double b, int nr, int ntheta).

The function ff takes Cartesian (x,y)(x,y) coordinates. Inside, convert (r,θ)(r, \theta) to (x,y)(x, y) and include the rr factor.

Use #include <math.h> for cos and sin.

TCC compiler loading...
Loading...
Click "Run" to execute your code.