7

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]]
Michael E2
  • 235,386
  • 17
  • 334
  • 747
Black Milk
  • 613
  • 5
  • 16
  • 2
    Given the UPDATED CODE what part of your question remains unanswered? – Mr.Wizard Sep 14 '14 at 06:56
  • 1
    @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. – Black Milk Sep 15 '14 at 22:49
  • 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$? –  Sep 15 '14 at 23:50
  • @RahulNarain, a parametric representation should be fine. – Black Milk Sep 16 '14 at 00:02
  • I struggle to understand. Would it be possible for you to create a picture of the output that you desire? (Hand drawn if necessary.) – Mr.Wizard Sep 16 '14 at 01:26
  • By the way, in the code and the figure you've plotted the hyperbola $xy=2$, but your equation (2) is equivalent to $xy=1$ instead. It's the latter that maps to the line $y=2$ as you desire. –  Sep 16 '14 at 06:08
  • @RahulNarain, right right, I completely overlooked that, equation (2) is what I intended. Thank you. – Black Milk Sep 16 '14 at 06:12

3 Answers3

7

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.

kglr
  • 394,356
  • 18
  • 477
  • 896
  • 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. – Black Milk Sep 15 '14 at 23:34
7

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.

  • Since you have succesfully defeated your laziness I take pride in upvoting your answer :) – eldo Sep 16 '14 at 03:16
  • 2
    I used to have a "systematic way to obtain a nice parametrization of an arbitrary conic" — it was called "Ask J. M." :) – rm -rf Sep 16 '14 at 06:05
  • That helper function will come in quite handy. – Black Milk Sep 16 '14 at 06:24
  • @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). –  Sep 16 '14 at 06:28
  • @rm, that "systematic way" of yours is a most inscrutable black box. :P – J. M.'s missing motivation May 02 '15 at 06:07
2

If you accept the position of the arrowheads ...

 r1 /. Line -> Arrow

enter image description here

eldo
  • 67,911
  • 5
  • 60
  • 168