Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I've got another plotting problem. I want to plot Sin[z] where z is complex. So, I've tried the following:

Plot3D[ Sin[ x + I y], {x, -1, 1}, {y, -1, 1}]

I wanted to see how the sine function looks like on the unit circle. But... I get no output. Am I doing something wrong or is the kernel stuck?

share|improve this question
    
You can plot Re[Sin[x + I*y]] and Im[Sin[x + I*y]] separately. –  b.gatessucks Jun 15 '12 at 15:35
    
Possible duplicate of Plotting Complex Quantity Functions –  Jens Aug 7 '12 at 16:36
    
See also Visualizing a Complex Vector Field near Poles –  Jens Aug 7 '12 at 16:37
    
@Jens It's not a duplicate of those posts since the OP asks for plot of sine on the unit circle, although the issue is quite similar. –  Artes Aug 7 '12 at 17:18
    
@Artes I see this as a special case of the linked question, but since you answered both, I'll go with your judgement here. –  Jens Aug 7 '12 at 17:27
add comment

2 Answers

up vote 23 down vote accepted

Well, you have to treat the real and imaginary parts separately. You can't really have a complex $z$ value in these plots. Here's one way to visualize complex sine:

Table[Plot3D[f[Sin[x + I y]], {x, -1, 1}, {y, -1, 1}, 
   PlotLabel -> TraditionalForm[f[Sin[z]]], 
   RegionFunction -> Function[{x, y, z}, x^2 + y^2 < 1]], {f, {Re, Im,
     Abs}}] // GraphicsRow

complex sine


One further visualization aid would be to color these functions by the argument (adapting a scheme by Roman Maeder):

Table[Plot3D[f[Sin[x + I y]], {x, -5, 5}, {y, -5, 5}, 
 ColorFunction -> Function[{x, y, z}, Hue[(Pi + If[z == 0, 0, Arg[Sin[x + I y]]])/(2Pi)]], 
 ColorFunctionScaling -> False, PlotLabel -> TraditionalForm[f[Sin[z]]], 
 RegionFunction -> Function[{x, y, z}, x^2 + y^2 < 25]],
{f, {Re, Im, Abs}}] // GraphicsRow

complex sine with argument coloring

As Artes notes, one could have used ParametricPlot3D[] so that you are directly working with polar coordinates:

Table[ParametricPlot3D[{r Cos[t], r Sin[t], f[Sin[r Exp[I t]]]},
       {r, 0, 5}, {t, -Pi, Pi}, BoxRatios -> OptionValue[Plot3D, BoxRatios], 
ColorFunction -> Function[{x, y, z}, Hue[(Pi + If[z == 0, 0, Arg[Sin[x + I y]]])/(2 Pi)]], 
ColorFunctionScaling -> False, PlotLabel -> TraditionalForm[f[Sin[z]]]],
{f, {Re, Im, Abs}}] // GraphicsRow

complex sine with argument coloring, 2

Yet another visualization possibility:

Table[ParametricPlot3D[{r Cos[t], r Sin[t], f[Sin[r Exp[I t]]]},
 {r, 0, 5}, {t, -Pi, Pi}, BoxRatios -> OptionValue[Plot3D, BoxRatios], 
 ColorFunction -> Function[{x, y, z}, Hue[(Pi + If[z == 0, 0, Arg[Sin[x + I y]]])/(2Pi)]], 
  ColorFunctionScaling -> False, MeshFunctions -> (#4 &), 
  MeshShading -> {Automatic, None}, MeshStyle -> Transparent, 
  PlotLabel -> TraditionalForm[f[Sin[z]]], PlotRange -> All],
{f, {Re, Im, Abs}}] // GraphicsRow

complex sine as polar ribbons

share|improve this answer
    
wow, that looks great. Thank you! –  Chris Jun 15 '12 at 15:43
add comment

You can plot in 3 dimensions only real and/or imaginary parts of a function. One can make use of Plot3D, but since there was a question how the sine function looks like on the unit circle, first I demonstrate usage of ParametricPlot3D and later I'll show a few of many possible uses of Plot3D.

When we'd like to use ParametricPlot3D, then instead of parametrizing complex numbers like x + I y we would rather parametrize them like r * Exp[ I u], where r is a radius of a circle and u is a polar angle. On a unit circle this reduces to Exp[ I u].

ParametricPlot3D[
    { { Cos[u], Sin[u], Re @ Sin[Exp[I u]]},
      { Cos[u], Sin[u], Im @ Sin[Exp[I u]]}},   {u, 0, 2 Pi}, 
      PlotStyle -> {{Thick, Darker @ Green}, {Thick, Darker @ Orange}}, BoxRatios -> Automatic]

enter image description here

It would be easier to realize the structure of the graph of Sine, rotating ParametricPlot3D around z axis. Thus we define the following functions :

F1[t_] := 
  Graphics3D[
    Rotate[ 
      ParametricPlot3D[ Table[{r Cos[u], r Sin[u], Re @ Sin[r Exp[I u]]}, {r, 0.1, 1, 0.1}],
                         {u, 0, 2 Pi}, PlotStyle -> Thick, 
                            ColorFunction -> (ColorData["DeepSeaColors"][#3] &), 
                            BoxRatios -> Automatic, Axes -> False, Boxed -> False][[1]], 
           2 Pi t, {0, 0, 1}], Boxed -> False]

F2[t_] := 
  Graphics3D[
    Rotate[
      ParametricPlot3D[ Table[{r Cos[u], r Sin[u], Im @ Sin[r Exp[I*(u)]]}, {r, 0.1, 1, 0.1}],
                        {u, 0, 2 Pi}, PlotStyle -> Thick, 
                        ColorFunction -> (ColorData["Rainbow"][#3] &), 
                        BoxRatios -> Automatic, Axes -> False, Boxed -> False][[1]], 
            2 Pi t, {0, 0, 1}], Boxed -> False]

now we can animate rotation around z-axis :

Animate[
    Show[{ F1[t], F2[t], 
           ParametricPlot3D[{{Cos[v], Sin[v], -1},
                             {Cos[v], Sin[v],  0}, 
                             {Cos[v], Sin[v],  1}  }, {v, 0, 2 Pi}, 
                             PlotStyle -> {Dashed, Dashed, Dashed}, BoxRatios -> Automatic, 
                             Axes -> False, Boxed -> False]}, 
           ViewPoint -> {Pi, Pi/2, 1/2}],
          {t, 0, 1},  DefaultDuration -> 15]

enter image description here

The "deepseacolors" and "rainbow" families of curves are respectively parametric 3D - plots of real and imaginary parts of Sine over circles of radius r in the complex plane and the view point rotates around z - axis. The dashed circles are unit circles in planes {x, y} for z in {-1, 0 , 1}. Here the rotation is surplus but still advantageous for the sake of comprehensible visualization.

Now we provide static 3-D plots of Sine in the complex plane.

GraphicsRow[{ 
    Plot3D[Re@Sin[x + I*y], {x, -2 Pi, 2 Pi}, {y, -2 Pi, 2 Pi}, ClippingStyle -> None], 
    Plot3D[Im@Sin[x + I*y], {x, -2 Pi, 2 Pi}, {y, -2 Pi, 2 Pi}, ClippingStyle -> None]}]

enter image description here

I extended the range of the plot to {x, -2 Pi, 2 Pi} and {y, -2 Pi, 2 Pi} since in your former case there was nothing interesting to see.

To compare with a familiar pattern of the graph of Sine let's restrict the range of the imaginary part of the variable, e.g.

GraphicsRow[{ Plot3D[ Re @ Sin[x + I*y], {x, -2 Pi, 2 Pi}, {y, -0.3 Pi, 0.3 Pi}], 
              Plot3D[ Im @ Sin[x + I*y], {x, -2 Pi, 2 Pi}, {y, -0.3 Pi, 0.3 Pi}]}]

enter image description here

or to get the equal scale for all dimensions

GraphicsRow[
  {Plot3D[ Re @ Sin[x + I*y], {x, -2 Pi, 2 Pi}, {y, -0.4 Pi, 0.4 Pi}, 
           BoxRatios -> Automatic, PlotLabel -> "Real part"], 

   Plot3D[ Im @ Sin[x + I*y], {x, -2 Pi, 2 Pi}, {y, -0.4 Pi, 0.4 Pi}, 
           BoxRatios -> Automatic, PlotLabel -> "Imaginary part"]     }, 

   PlotLabel -> "Graphs of Sine"]

enter image description here

and if you prefer the both parts of Sine in the complex plane in one plot :

Plot3D[{ Re @ Sin[x + I*y], Im @ Sin[x + I*y]},
       {x, -2 Pi, 2 Pi}, {y, -0.4 Pi, 0.4 Pi}, 
         Mesh -> {5, 3}, BoxRatios -> Automatic, 
         PlotStyle -> {{Opacity[0.35], Lighter[Green, 0.5]},
                       {Opacity[0.7],  Lighter[Blue,  0.7]} } ]

enter image description here

share|improve this answer
    
Thank you Artes! –  Chris Jun 15 '12 at 15:44
1  
+1 for generating a beautiful plot! –  David Skulsky Jun 16 '12 at 13:03
    
@DavidSkulsky Thank You ! –  Artes Jun 16 '12 at 15:43
1  
For a different visualization, on the Riemann sphere, see the paper "Visualizing Complex Functions with the Presentations Application," The Mathematica Journal, vol. 11 #2 (2009), by David J. M. Park and me. Available in CDF and PDF here. (To re-evaluate most code, and to run the dynamic examples, you'll need a copy of Park's Presentations application.) –  murray Aug 7 '12 at 16:57
    
@murray Thank you for pointing out interesting references. I've seen that paper. –  Artes Aug 7 '12 at 17:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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