# Plotting the region bounded by parallel lines

I am working on the integral $$\int\int_D (2x+y)^2 e^{x-y}dA,$$ where $D$ is the region bounded by $2x+y=1$, $2x+y=4$, $x-y=-1$, and $x-y=1$. I need to shade the region bounded by these lines, so I let $u=2x+y$ and $v=x-y$, and the lines became $u=1$, $u=4$, $v=-1$, and $v=1$. Then I solved:

Solve[{u == 2 x + y, v == x - y}, {x, y}, Reals]

{{x -> u/3 + v/3, y -> u/3 - (2 v)/3}}


Then I did this (thanks to MichaelE2):

ParametricPlot[{(u + v)/3, (u - 2 v)/3}, {u, 1, 4}, {v, -1, 1},
PlotRange -> {{-1, 2}, {-1, 3}},
AspectRatio -> Automatic,
Axes -> True, AxesLabel -> {"x", "y"}, GridLines -> Automatic]


Which gave the correct shaded region.

However, is there some cute Mathematica method that would give me this shaded region without this thinking, solving, approach?

edit I have corrected omission of absolute value determinant. I am not currently able to access Mathematica but will correct image accordingly but till then just noted sign difference. Apologies.

Just another way (including @belisarius region) change of variable (for this case can use affine transform to plot):

mat = {{2, 1}, {1, -1}};
rect = Rectangle[{1, -1}, {4, 1}];
ireg = ImplicitRegion[1 < 2 x + y < 4 && -1 < x - y < 1, {x, y}];
j = Det[Inverse@mat];


where mat is just the matrix form, rect is "uv" plane region, j is Jacobian for change of variable.

So illustrating region (and relation to "uv" plane) and integration:

g1 = Graphics[GeometricTransformation[rect, Inverse@mat],
Frame -> True,PlotLabel -> "xy plane"];
g2 = RegionPlot[ireg, AspectRatio -> Automatic];
i1 = HoldForm@Integrate[u ^2 Exp[v] Abs[j], {u, v} \[Element] rect];
r1 = ReleaseHold@i1;
i2 = HoldForm@Integrate[(2 x + y) ^2 Exp[x - y], {x, y} \[Element] ireg];
r2 = ReleaseHold@i2;
Grid[{{Graphics[rect, PlotLabel -> "uv plane"] <-> g1, g2}, {i1,
i2}, {r1, r2}}, Frame -> All, Spacings -> {1, 1}]


• Fabulous! Do you think you could do a nonlinear example for me, namely $\int\int_R\ y^2\,dA$, where $R$ is the region bounded by $xy=1$, $xy=2$, $xy^2=1$, and $xy^2=2$? Aug 19, 2015 at 16:19
• One small error to correct here. Should be Abs[j]. Aug 19, 2015 at 21:44
• @David yes should be Abs[j]...will correct when I have time or you can correct with edit...time zone issues and have only had 2 hours sleep and full day work ahead so will not get to for a while... Aug 19, 2015 at 21:47
• @ubpqdn I also updated the image. Aug 20, 2015 at 2:02
RegionPlot[1 < 2 x + y < 4 && -1 < x - y < 1, {x, -1, 2}, {y, -1, 3}]


• I have learned a huge amount from this page. Thanks for the help. Aug 19, 2015 at 16:20
• @David Glad to hear that! Aug 19, 2015 at 16:22

Not the simplest solution, but a clever one:

eqs1 = {2 x + y == 1, 2 x + y == 4};
eqs2 = {x - y == -1, x - y == 1};

cornerPts =
Flatten[({x, y} /. Outer[Solve[#1 && #2, {x, y}] &, eqs1, eqs2]), 2];


or

cornerPts =
Flatten[({x, y} /.
Outer[Solve[2 x + y == #1 && x - y == #2, {x, y}] &,
{1, 4}, {-1, 1}]), 2];

ConvexHullMesh[cornerPts]

• Amazing use of Outer and Flatten. What a cool way to find the points of intersection of four curves. And thank for the intro to ConvexHullMesh. Aug 19, 2015 at 16:22