Lesson 14 of 18

Polar Area

Polar Area

In polar coordinates, a curve is defined by radius as a function of angle: r=r(heta)r = r( heta).

The area enclosed by a polar curve from heta=a heta = a to heta=b heta = b:

A = rac{1}{2} int_a^b [r( heta)]^2 , d heta

Why the Formula Works

Each infinitesimal slice at angle heta heta is a sector with radius r(heta)r( heta) and angle dhetad heta. A sector's area is rac{1}{2}r^2 d heta (fraction of circle area pir2pi r^2).

Classic Examples

Full circle r=Rr = R on [0,2pi][0, 2pi]:

A = rac{1}{2} int_0^{2pi} R^2 , d heta = rac{1}{2} cdot R^2 cdot 2pi = pi R^2

Semicircle r=1r = 1 on [0,pi][0, pi]:

A = rac{1}{2} int_0^{pi} 1 , d heta = rac{pi}{2} approx 1.5708

Rose curves and limaçons: more complex integrands requiring numerical integration.

Numerical Approach

Apply the midpoint rule:

#define PI 3.14159265358979
double h = (b - a) / n;
for each midpoint θ:
    double r = r_fn(θ);
    sum += r * r;
return 0.5 * sum * h;

Your Task

Implement double polar_area(double (*r_fn)(double), double a, double b, int n).

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