Compute $$\iint_D4\cos^2{(2x+y)} \ dxdy,$$
where $D=\{2\leq 2x+y \leq 6, \ x\geq0, \ y\geq 0 \}.$
I want to make an apropriate change of variables. But to see what works, Here is a picure of the area:
So I realise that $u=2x+y$ is ok, but what should I set $v=$ to?

Exact evaluation
For convenience, I set $v$ as the $u$-axis rotated by $90°$ anticlockwise. i.e. $v = -x + 2y$.
\begin{align} \begin{bmatrix}u \\ v\end{bmatrix} &= \begin{bmatrix}2 & 1 \\ -1 & 2 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} \\ \begin{bmatrix} x \\ y \end{bmatrix} &= \begin{bmatrix}2 & 1 \\ -1 & 2 \end{bmatrix}^{-1} \begin{bmatrix} u \\ v \end{bmatrix} = \begin{bmatrix}2/5 & -1/5 \\ 1/5 & 2/5 \end{bmatrix} \begin{bmatrix} u \\ v \end{bmatrix} \end{align}
Find the boundaries of $D$.
Compute the Jacobian determinant.
$$\left|\frac{\partial(u,v)}{\partial(x,y)}\right| = \begin{vmatrix}2 & 1 \\ -1 & 2 \end{vmatrix} = 5$$ $$\left|\frac{\partial(x,y)}{\partial(u,v)}\right| = \frac15$$
\begin{align} \iint_D4\cos^2{(2x+y)} \ dxdy, &= \int_2^6 \int_{-u/2}^{2u} 4 \cos^2 u \cdot \frac15 dvdu \\ &= \frac45 \int_2^6 \frac52u \cdot \frac{1+\cos(2u)}{2} du \\ &= \int_2^6 (u + u\cos(2u)) du \\ &= \frac{6^2-2^2}{2} + \left[ \frac{u\sin(2u)}{2} \right]_2^6 - \int_2^6 \frac{\sin(2u)}{2} du \\ &= 16 + 3\sin(12)-\sin(4) + \frac{\cos(12)}{4}-\frac{\cos(4)}{4} \end{align}
Monte-Carlo estimation
I typed this section for fun. Sometimes $D$ has a boundary that can only be expressed as implicit functions. In this case, the
MonteCarlo_doublemethod in the book Programming for Computations will be useful.The function
fis the integrand, andgselects the points in $D$. (i.e. $g = 1_D - 1_{D^C}$)MonteCarlo_doubleestimates $\text{Area of }D \times \Bbb{E}[f(X_i)1_D]$, where $X_i \sim \mathrm{Unif}([0,3] \times [0,6])$.An difference of about $0.03$ is observed when $n^2 = (10^4)^2 = 10^8$ points are randomly selected in the rectangle $[0,3] \times [0,6]$. The hand-calculated value above is close enough to the Monte-Carlo estimation.
N.B.: The syntax for
printin Python 2.7 differs from its counterpart in 3.4. This estimation is a verification of an answer, but it's never an answer.