<s>[INST] Double integral of maximum function. Let $D:= \lbrace (x,y) \in [0,\infty)^2: 1 \le x^2+y^2\le9 \rbrace$.
Determine the integral :
$$\int\int_D \max(3x^2,y^2)\;dx\,dy.$$
I have a little problem, because I'm not sure where the maximum is $3x^2$ or $y^2$.
 [/INST] Let $x=r\cos\theta$ and $y=r\sin\theta$, then 
$$
\iint_D \max\{3x^2,y^2)\ \mathsf dx\ \mathsf dy = \iint_D \det J\cdot\max\{3r^2\cos^2\theta, r^2\sin^2\theta \}\ \mathsf d\theta\ \mathsf d r,
$$
where
$$
J = \begin{bmatrix}\frac{\partial x}{\partial r}&\frac{\partial x}{\partial \theta}\\ \frac{\partial y}{\partial r}&\frac{\partial y}{\partial \theta}
\end{bmatrix} 
= \begin{bmatrix} \cos\theta&-r\sin\theta\\ \sin\theta& r\cos\theta
\end{bmatrix}.
$$
The determinant of the Jacobian matrix is
$$
\det J = \cos\theta\cdot r\cos\theta - (-r\sin\theta\cdot\sin\theta) = r(\sin^2\theta + \cos^2\theta) = r,
$$
and so the integral in question is
$$
\int_1^3\int_0^{2\pi} r\cdot\max\{3r^2\cos^2\theta,r^2\sin^2\theta\}\ \mathsf d\theta\ \mathsf dr = \int_1^3 r^3\int_0^{2\pi} \max\{3\cos^2\theta,\sin^2\theta\}\ \mathsf d\theta\ \mathsf dr.
$$
To compute $\max\{3\cos^2\theta,\sin^2\theta\}$, first note that
\begin{align}
3\cos^2\theta = \sin^2\theta &\iff \sqrt 3|\cos\theta| = |\sin\theta|\\
&\iff \frac{|\sin\theta|}{|\cos\theta|} = \sqrt 3\\
&\iff \theta \in \left\{\frac\pi3, \frac{2\pi}3,\frac{4\pi}3,\frac{5\pi}3 \right\}.
\end{align}
Hence
\begin{align}
&\quad\int_1^3r^3\int_0^{2\pi} \max\{3\cos^2\theta,\sin^2\theta\}\ \mathsf d\theta\ \mathsf dr\\
&= \int_1^3 r^3 \bigg(\int_0^{\frac\pi3}3\cos^2\theta\ \mathsf d\theta + \int_{\frac\pi3}^{\frac{2\pi}3} \sin^2\theta\ \mathsf d\theta + \int_{\frac{2\pi}3}^{\frac{4\pi}3}3\cos^2\theta\ \mathsf d\theta \\
&\quad\quad\quad+\int_{\frac{4\pi}3}^{\frac{5\pi}3}\sin^2\theta\ \mathsf d\theta + \int_{\frac{5\pi}3}^{2\pi} 3\cos^2\theta \bigg) \mathsf d\theta\\
&=40\sqrt3 + \frac{140\pi}3.
\end{align}
</s>