I have the following definite double integral.
$\int _0^{\frac{d}{1-r}}\int _{\frac{d+r x-x}{r}}^s [(1-r) x+r y -d]dydx$
with the constraints: $0\leq d \leq 1$, $1 \leq s \leq 4$, $0 \leq r \leq 1$, $0 \leq x \leq s$, $0\leq y \leq s$.
My code for solving this integration is
Integrate[(1 - r)*x + r*y - d, {x, 0, d/(1 - r)}, {y, (d + r*x - x)/r,s}]
And I got
(d^3 - 3 d^2 r s + 3 d r^2 s^2)/(6 r - 6 r^2)
But I think this is not correct because the variables $x$ and $y$ are bounded by $0$ and $s$ and therefore I think I need additional constraints on the limits, i.e.
$\frac{d}{1-r}\leq s$ and $0 \leq \frac{d+rx-x}{r} \leq s$.
And I'm wondering how to add these two constraints in solving the above integration. Can anyone help please? Thanks!
{Integrate[((1 - r)*x + r*y - d), {#4[[2]], #4[[1]], #4[[3]]}, {#5[[2]], #5[[1]], #5[[3]]}, Assumptions -> {0 <= d <= 1, 1 <= s <= 4, 0 <= r <= 1, #1, #2, #3}], And[#1, #2, #3]} & @@@ List @@ (Reduce[#, {d, s, r, x, y}] & /@ BooleanConvert@ Reduce[{0 < d < 1, 1 < s < 4, 0 <= r <= 1, 0 <= x <= s, 0 <= y <= s, 0 < x < d/(1 - r), (d + r*x - x)/r < y < s}, {d, s, r, x, y}]) // Piecewise // PiecewiseExpand
$\endgroup$