7
$\begingroup$

I'm working on a complex transformation sketch that I'd like to create via mathematica. I'm working with the function $$w=z^2\tag{0},$$ where its real and imaginary parts are $u=x^2-y^2$ and $v=2xy$, respectively. Now, I want to sketch the image under the given transformation of each branch of the hyperbola $$x^2-y^2=1\tag{1}$$ where the right and left branches (in blue) are oriented upward and downwards, respectively. For example, the blue branches of the hyperbola in (1) appear as such:

enter image description here

Similarly, for the hyperbola $$2xy=2,\tag{2}$$the left and right branches (in orange) are oriented upwards and downwards, respectively.

How do I sketch the images of these hyperbolas under the complex function $w=z^2$, while taking into account the orientation of their respective branches? By 'image' I mean to say the image of the function (0) applied to the hyperbolas (1) and (2). I expect the image of the hyperbola (under $w$) in (1), to be the line $u=1$, oriented updwards, and the image of the hyperbola (under $w$) in (2) to be the line $v=2$, oriented rightwards.

Here's what I have so far; however, getting the orientation arrows requires that I load the CurvesGraphics6 package from here.

 r1 = ContourPlot[{x^2 - y^2 == 1, x*y == 1}, {x, -4, 4}, {y, -4, 4}, 
 Axes -> True, Frame -> False, PlotRange -> Automatic, 
 Background -> White, Oriented -> True]

[UPDATED CODE] Courtesy of Eldo and Mark McClure, I was able to apply orientation arrows to the Hyperbolas without using the aforementioned package.

r1 = ContourPlot[{x^2 - y^2 == 1, x*y == 1}, {x, -4, 4}, {y, -4, 4}, 
Axes -> True, Frame -> False, PlotRange -> Automatic, 
Background -> White]

Show[r1, r1 /. Line[pts_] :> Arrow[pts, 2]]
$\endgroup$
  • 2
    $\begingroup$ Given the UPDATED CODE what part of your question remains unanswered? $\endgroup$ – Mr.Wizard Sep 14 '14 at 6:56
  • 1
    $\begingroup$ @Mr.Wizard The part where images of these hyperbolas under the transformation $w=z^2$ are the lines u=1 and v=2, oriented upwards and rightwards, respectively. I think there's a misunderstanding of what I mean by 'image', as I mean it in a mathematical sense. $\endgroup$ – Black Milk Sep 15 '14 at 22:49
  • $\begingroup$ Would you be okay with replacing the implicit form $x^2-y^2=1$ with a parametric representation, say $x=\pm\cosh t,y=\pm\sinh t$? $\endgroup$ – Rahul Sep 15 '14 at 23:50
  • $\begingroup$ @RahulNarain, a parametric representation should be fine. $\endgroup$ – Black Milk Sep 16 '14 at 0:02
  • $\begingroup$ I struggle to understand. Would it be possible for you to create a picture of the output that you desire? (Hand drawn if necessary.) $\endgroup$ – Mr.Wizard Sep 16 '14 at 1:26
7
+50
$\begingroup$

I suspect that ContourPlot doesn't really have a notion of the orientation of curves in a way that will let you preserve them after applying arbitrary transformations. ParametricPlot is probably the way to go.

Start with parametric representations of the hyperbolas with the desired orientation:

hyperbola1[t_] := {#, -#} &@{Csc[t], -Cot[t]};
hyperbola2[t_] := {#, -#} &@{Tan[t/2], Cot[t/2]};
ParametricPlot[{hyperbola1[t], hyperbola2[t]}, {t, 0, π}, 
  PlotRange -> {-4, 4}, RegionFunction -> Function[{x, y}, -4 <= x <= 4 && -4 <= y <= 4], 
  PlotStyle -> Arrowheads[{{Automatic, 0.5}}]] /. Line -> Arrow

enter image description here

(Thanks to @kguler for the cool Arrowheads trick. And yes, I've sort of pulled these parametrizations "out of a hat" with a bit of trial and error... It would be nice to have a systematic way to obtain a nice parametrization of an arbitrary conic, but that's beyond the scope of this answer.)

Your function $w$ maps complex numbers to complex numbers, so we define a little helper function to map 2D points to 2D points. Then we can directly plot the image of the hyperbolas under that transformation.

w[z_] := z^2;
apply[w_, pts_] := Through@{Re, Im}@w@({1, I}.#) & /@ pts
ParametricPlot[{apply[w, hyperbola1[t]], apply[w, hyperbola2[t]]}, {t, 0, π}, 
  PlotRange -> {-4, 4}, RegionFunction -> Function[{x, y}, -4 <= x <= 4 && -4 <= y <= 4], 
  PlotStyle -> Arrowheads[{{Automatic, 0.5}}]] /. Line -> Arrow

enter image description here

Note that the only thing we've changed in the plot is the functions we're plotting: apply[w, hyperbola[t]]. Also note that the orientation of the arrows is consistent with the previous plot.

$\endgroup$
  • $\begingroup$ Since you have succesfully defeated your laziness I take pride in upvoting your answer :) $\endgroup$ – eldo Sep 16 '14 at 3:16
  • 2
    $\begingroup$ I used to have a "systematic way to obtain a nice parametrization of an arbitrary conic" — it was called "Ask J. M." :) $\endgroup$ – rm -rf Sep 16 '14 at 6:05
  • $\begingroup$ That helper function will come in quite handy. $\endgroup$ – Black Milk Sep 16 '14 at 6:24
  • $\begingroup$ @Black Milk: Well, I should point out that the helper function is a little more complicated because my hyperbolas are secretly two curves each. If you want to apply $w$ to a single point $p$ you would do the slightly simpler Through@{Re, Im}@w@({1, I}.p). $\endgroup$ – Rahul Sep 16 '14 at 6:28
  • $\begingroup$ @rm, that "systematic way" of yours is a most inscrutable black box. :P $\endgroup$ – J. M. will be back soon May 2 '15 at 6:07
7
$\begingroup$

Still guessing... is the expected output something like the following?

ContourPlot[{Re[(u + I v)^2] == 1, Im[(u + I v)^2] == 2, u == 1,  v == 2},
             {u, -4, 4}, {v, -4, 4}, 
             Axes -> True, Frame -> False, 
             BaseStyle -> Arrowheads[{{.05, .5}}], PlotLegends -> "Expressions", 
             ContourStyle -> Thread[{ColorData[1, "ColorList"][[;; 4]], Arrow @@ ## &}]]

enter image description here


Original post:

An alternative approach that does not require post-processing using a function for the option ContourStyle:

ContourPlot[{x^2 - y^2 == 1, x*y == 2}, {x, -4, 4}, {y, -4, 4},
 Axes -> True, Frame -> False,
 PlotRange -> Automatic, Background -> White,
 BaseStyle -> Arrowheads[{{.05, .5}}],
 ContourStyle -> Thread[{ColorData[1, "ColorList"][[;; 2]], Arrow @@ ## &}]]

enter image description here

Use BaseStyle ->Arrowheads[Table[.05, {5}]] to get multiple Arrowheads:

enter image description here

Note: You can also specify the Arrowheads directive inside ContourStyle

ContourStyle->Thread[{ColorData[1, "ColorList"][[;;2]], Arrowheads[{{.05, .5}}], Arrow @@ ##&}]

or

ContourStyle->Thread[{ColorData[1, "ColorList"][[;;2]],Arrowheads[Table[.05, {5}]], Arrow @@ ##&}]

instead of using BaseStyle.

$\endgroup$
  • $\begingroup$ I think there was a misunderstanding on what I meant by image. It's my fault for not elaborating on what I meant, so please refer to the updated text in bold-italics. Thanks. $\endgroup$ – Black Milk Sep 15 '14 at 23:34
2
$\begingroup$

If you accept the position of the arrowheads ...

 r1 /. Line -> Arrow

enter image description here

$\endgroup$
  • $\begingroup$ This should be posted as a comment if it partially addresses the question. I upvoted your answer,anyhow. I expect to reupdate my post using your suggestion. $\endgroup$ – Black Milk Sep 10 '14 at 14:21
  • 2
    $\begingroup$ How about Show[r1, r1 /. Line[pts_] :> Arrow[pts, 2]]? $\endgroup$ – Mark McClure Sep 10 '14 at 14:22
  • $\begingroup$ @MarkMcClure that's more like it! $\endgroup$ – Black Milk Sep 10 '14 at 14:25
  • 1
    $\begingroup$ To more closely match the original plot you can specify separate offsets: d = {4.9, 4.9, 2.65, 2.65}; n = 1; Show[r1, r1 /. Line[pts_] :> Arrow[pts, d[[n++]]]] $\endgroup$ – Bob Hanlon Sep 10 '14 at 15:55

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.