I have some function $\psi$, I compute the transformation $T = \vec{x} - \nabla \psi$. I'd like to visualize the action of $T$ on a square centered at the origin.

The mathematica website shows some examples of how to compute transformations.


I have two questions:

  1. If I want to subimpose the initial region (perhaps in red) under the final region, how would I do this? Also I'd like to add coordinate axes.

  2. Below is included a sketch of code. How do I get the coordinates of the gradient I compute into the transformation function. Below is my best guess, but I'm totally lost on how to accomplish this.

psi = -4 (x^2 + y^2);
gradPsi = Grad[psi, {x, y}]; /. {Indexed[#, 1] -> x , 
  Indexed[#, 2] -> y}
R = 
   Rectangle[], {Indexed[#, 1] - Indexed[gradPsi, 1], 
     Indexed[#, 2] + Indexed[gradPsi, 2]} &];

1 Answer 1

psi = -4 (x^2 + y^2);

gradPsi = Grad[psi, {x, y}]

R = TransformedRegion[Rectangle[], {Indexed[#, 1] - First@gradPsi /. x -> #[[1]], 
     Indexed[#, 2] + Last@gradPsi /. y -> #[[2]]} &];

Show[Graphics[{Opacity[.5], Blue, Rectangle[]}], 
 RegionPlot[R, PlotStyle -> Opacity[.5, Red]], 
 PlotRange -> All, Frame -> True, FrameTicks -> All]

enter image description here

  • $\begingroup$ Almost there, thanks!! I meant to say the center of the square is centered at the origin. I think this is the bottom left corner. I'm having a little trouble interpreting the picture. For the example I showed, the Transformation should blow up a box whose center is at the origin by a factor of 9. $T = \langle x - (-8x), y - (-8y) \rangle$ $\endgroup$
    – yoshi
    Commented Dec 21, 2020 at 17:36
  • 1
    $\begingroup$ Ah got it, thanks! There's a typo in the formula, and the box can be recentered using documentation. $\endgroup$
    – yoshi
    Commented Dec 21, 2020 at 17:46

Your Answer

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

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