<s>[INST] Iterated Integral with variable substitution I need to calculate the double integral of the function $f(x,y) = (x+y)^9(x-y)^9$:  
$\int_0^{1/2} \int_x^{1-x}  (x+y)^9(x-y)^9 dydx$
I have a solution but I definitely arrived at it after a sloppy attempt. I got -0.0025. To begin with, I know you need to separate the variables. I tried integration by parts, but got lost in it. How can I separate the variables to continue the integration?
 [/INST] It's convenient to solve this integral with substitution. Since we want to separate the variables in the Integral
\begin{align*}
\int_0^{1/2} \int_x^{1-x}  (x+y)^9(x-y)^9 dy\,dx\tag{1}
\end{align*}
it's reasonable to use  the substitution
\begin{align*}
\left.
\begin{matrix}
u=x+y\\
v=x-y\\
\end{matrix}
\right\}
\quad\Longleftrightarrow\quad
\left\{
\begin{matrix}
x=\frac{1}{2}(u+v)\\
y=\frac{1}{2}(u-v)
\end{matrix}
\right.\tag{2}
\end{align*}

According to the Change of variable theorem we want to calculate
  \begin{align*}
\int_{x_0}^{x_1}\int_{y_0}^{y_{1}}f(x,y)\,dy\,dx
=\int_{u_0}^{u_1}\int_{v_0}^{v_{1}}f(x(u,v),y(u,v))
\left|\operatorname{det}
\begin{pmatrix}
x_u&x_v\\
y_u&y_v
\end{pmatrix}
\right|
\,dv\,du\tag{3}
\end{align*}
Jacobian
At first we calculate the absolute value of the determinant of the Jacobian matrix
  \begin{align*}
\left|\operatorname{det}
\begin{pmatrix}
x_u&x_v\\
y_u&y_v
\end{pmatrix}
\right|=
\left|\operatorname{det}
\begin{pmatrix}
\frac{1}{2}&\frac{1}{2}\\
\frac{1}{2}&-\frac{1}{2}
\end{pmatrix}
\right|
=\frac{1}{2}
\end{align*}
Area transformation
We observe from (1) the region of integration is 
  \begin{align*}
&0\leq x\leq \frac{1}{2}\\
&x\leq y\leq 1-x
\end{align*}
This is the area of a triangle with three lines as boundary lines,  the $y$-axis  $x=0$, the  major diagonal $x=y$ and a parallel to the minor diagonal through $(1,0)$, $y=1-x$.
Since the transformation (2) is linear, lines are transformed to lines. So, the transformed $(u,v)$-area is again enclosed by three lines.
\begin{array}{lclcl}
x=0\qquad&\rightarrow&\qquad \frac{1}{2}(u+v)=0
&\qquad\rightarrow&u=-v\\
x=y\qquad&\rightarrow&\qquad \frac{1}{2}(u+v)=\frac{1}{2}(u-v)
&\qquad\rightarrow&v=0\\
y=1-x\qquad&\rightarrow&\qquad \frac{1}{2}(u-v)=1-\frac{1}{2}(u+v)
&\qquad\rightarrow&u=1\\
\end{array}
We see the $(u,v)$-triangle area is given by the three lines $u=-v, v=0$ and $u=1$ which can be written as
  \begin{align*}
0\leq u \leq 1\\
-u\leq v\leq 0
\end{align*}

$$ $$

Integration
Now we have all ingredients to perform the integration according to (3). We obtain
\begin{align*}
\int_0^\frac{1}{2}\int_x^{1-x}  (x+y)^9(x-y)^9 dy\,dx
&=\int_0^1\int_{-u}^0(uv)^9\cdot\frac{1}{2}\,dv\,du\\
&=\frac{1}{2}\int_0^1u^9\left(\int_{-u}^0v^9\,dv\right)\,du\\
&=\frac{1}{2}\int_0^1u^9\left(\left.\frac{1}{10}v^{10}\right|_{-u}^0\right)\,du\\
&=-\frac{1}{20}\int_0^1u^{19}\,du\\
&=-\frac{1}{20}\left.\left(\frac{1}{20}u^{20}\right)\right|_{0}^1\\
&=-\frac{1}{400}
\end{align*}

</s>