# Visualize transformation used in multiple integration

In class, we will sketch the region $D$ in $R^2$ bounded by the curves $xy=1$, $xy=4$, $y=x$, and $y=x+2$. Then we will use the change of variables given by $u=xy$ and $v=y-x$. We need to show that this change of variables maps region $D^*=\{(u,v): 1\le u\le 4,\ 0\le v\le 2\}$ onto the region $D$.

Now, I know how to use Mathematica to sketch both of these regions, but I wonder if folks here could share code for visualizing how the indicated transformation transforms one region into the other.

• Have you seen TransformedRegion[]? Aug 14, 2015 at 16:32
• In addition to @Guesswhoitis. suggestion, it could be fun to illustrate things with ImageTransformation. E.g., if you take an image with a regular pattern on it, then the transformation will also help explain the change in density that corresponds to the Jacobi determinant.
– Jens
Aug 14, 2015 at 16:53

Not so fancy as transforming an image, but I like how the mesh in ParametricPlot shows the deformation.

{chvar} = Simplify[
Solve[u == x y && v == y - x && y > 0 && x > 0, {x, y}, Reals],
1 <= u <= 4 && 0 <= v <= 2]
(*  {{x -> (2 u)/(v + Sqrt[4 u + v^2]), y -> 1/2 (v + Sqrt[4 u + v^2])}}  *)

With[{mesh = Range[-4, 6, 1/4]},
Show[
ParametricPlot[{x, y} /. chvar, {u, 0.002, 6}, {v, -4, 4}, Mesh -> {mesh, mesh}],
ParametricPlot[{x, y} /. chvar, {u, 1, 4}, {v, 0, 2}, Mesh -> {mesh, mesh},
PlotStyle -> Red]
]]


Each mesh quadrilateral is the image of a square in the uv plane with the same dimensions 1/4 x 1/4. The difference of the areas in the graphics represents the Jacobian factor.

(Note that the mesh was chosen explicitly to make the boundary align with the mesh.)

With ElementMesh you can color the mesh according to the area.

Needs["NDSolveFEM"];
uvmesh = ToElementMesh[Rectangle[{1, 0}, {4, 2}],
MaxCellMeasure -> {"Length" -> 1/4}];

dx = Function[{u, v}, x - u /. chvar // Evaluate];
dy = Function[{u, v}, y - v /. chvar // Evaluate];

dxifn = ElementMeshInterpolation[{uvmesh}, dx @@@ uvmesh["Coordinates"]];
dyifn = ElementMeshInterpolation[{uvmesh}, dy @@@ uvmesh["Coordinates"]];

xymesh = ElementMeshDeformation[uvmesh, {dxifn, dyifn}];

With[{mesh = Range[-4, 6, 1/4]},
Show[
ParametricPlot[{x, y} /. chvar, {u, 0.002, 6}, {v, -4, 4}, Mesh -> {mesh, mesh}],
Graphics[
ElementMeshToGraphicsComplex[xymesh, All] /.
Polygon[pp_] :> Riffle[
ColorData["TemperatureMap"] /@
Rescale[First@ElementMeshElementMeasure[xymesh]],
Polygon /@ pp]],
xymesh["Wireframe"]]
]


• Why have Method -> Reduce here? Aug 14, 2015 at 17:56
• @ChipHurst Thanks. It's an artifact of the first thing I tried failing. Forgot to see if it was ultimately necessary, which it's not. Aug 14, 2015 at 18:01
• Gotcha. I thought it might have been to deal with backward compatibility or something. Aug 14, 2015 at 18:03