4
$\begingroup$

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.

enter image description here

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

$\endgroup$
4
$\begingroup$

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}]

enter image description here

|improve this answer|||||
$\endgroup$
  • $\begingroup$ 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$? $\endgroup$ – David Aug 19 '15 at 16:19
  • $\begingroup$ One small error to correct here. Should be Abs[j]. $\endgroup$ – David Aug 19 '15 at 21:44
  • $\begingroup$ @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... $\endgroup$ – ubpdqn Aug 19 '15 at 21:47
  • $\begingroup$ @ubpqdn I also updated the image. $\endgroup$ – David Aug 20 '15 at 2:02
9
$\begingroup$
RegionPlot[1 < 2 x + y < 4 && -1 < x - y < 1, {x, -1, 2}, {y, -1, 3}]

Mathematica graphics

|improve this answer|||||
$\endgroup$
  • $\begingroup$ I have learned a huge amount from this page. Thanks for the help. $\endgroup$ – David Aug 19 '15 at 16:20
  • $\begingroup$ @David Glad to hear that! $\endgroup$ – Dr. belisarius Aug 19 '15 at 16:22
3
$\begingroup$

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]
|improve this answer|||||
$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – David Aug 19 '15 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.