5
$\begingroup$

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.

$\endgroup$
2
  • 6
    $\begingroup$ Have you seen TransformedRegion[]? $\endgroup$ Aug 14, 2015 at 16:32
  • 6
    $\begingroup$ 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. $\endgroup$
    – Jens
    Aug 14, 2015 at 16:53

1 Answer 1

9
$\begingroup$

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

Mathematica graphics

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["NDSolve`FEM`"];
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"]]
 ]

Mathematica graphics

$\endgroup$
3
  • $\begingroup$ Why have Method -> Reduce here? $\endgroup$
    – Greg Hurst
    Aug 14, 2015 at 17:56
  • $\begingroup$ @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. $\endgroup$
    – Michael E2
    Aug 14, 2015 at 18:01
  • $\begingroup$ Gotcha. I thought it might have been to deal with backward compatibility or something. $\endgroup$
    – Greg Hurst
    Aug 14, 2015 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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