Solution (source code)

= Solution

The <cardioid> has a nonnegative radial boundary, so each ray from the origin contributes $0\le r\le a(1+\cos\theta)$. Integrating the <polar coordinates> <area element> yields
$$
A=\int_0^{2\pi}\int_0^{a(1+\cos\theta)}r\,dr\,d\theta
=\frac{a^2}2\int_0^{2\pi}(1+2\cos\theta+\cos^2\theta)\,d\theta.
$$
The three angular integrals are $2\pi$, zero and $\pi$, respectively, using the <double-angle formula> for the last. Thus
$$
\boxed{A=\frac{3\pi a^2}{2}.}
$$