1
$\begingroup$

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.

https://reference.wolfram.com/language/ref/TransformedRegion.html

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.

Clear["Global`*"]
psi = -4 (x^2 + y^2);
gradPsi = Grad[psi, {x, y}]; /. {Indexed[#, 1] -> x , 
  Indexed[#, 2] -> y}
R = 
  TransformedRegion[
   Rectangle[], {Indexed[#, 1] - Indexed[gradPsi, 1], 
     Indexed[#, 2] + Indexed[gradPsi, 2]} &];
Region[R]
$\endgroup$
1
$\begingroup$
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

$\endgroup$
2
  • $\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 Dec 21 '20 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 Dec 21 '20 at 17:46

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.