Graphical representation of the complex tangent function

David Park
djmp@earthlink.net
http://home.earthlink.net/~djmp/

Updated to use Cardano3 application instead of its predecessor application ComplexAnalysis.
Edited and revised slightly by Murray Eisenberg.

Initialization

Load David Park's Cardano3 application packages.

Needs["Cardano3`ComplexGraphics`"]
Needs["Cardano3`ComplexRoutines`"]

Turn off some annoying warning messages that might otherwise appear about similarly-named objects.  (If you want to see these messages so as to be sure to avoid harm, evaluate expressions like the ones below but replace Off there by On.)

Off[General::spell]
Off[General::spell1]

The function tan

Plots of the real and imaginary parts of tan(x + i y)

\(\(TwoPanelPlot[
{{Tan, Re}, 
          CartesianSurface, \ {0, π}, {LightSkyBlue}}, 
{{Tan, Im}, 
          CartesianSurface, \ \ {0, π}, {LightCoral}}];\)\)

A wider view...

\(\(TwoPanelPlot[
{{Tan, Re}, 
          CartesianSurface, \ {0, 
            4  π}, {LightSkyBlue}, {}, {PlotPoints -> 30}}, 
{{Tan, 
            Im}, CartesianSurface, \ \ {0, 
            4  π}, {LightCoral}, {}, {PlotPoints -> 
              30}}];\)\)

Contour plot of the modulus |tan z|

We will plot it about a peak at π/2.

OnePanelPlot[{Tan, Abs}, 
        CartesianContour, {π/2, π/2}, {{0, 0.2, 0.5, 1, 2, 5, 
            10}, {0.2, 0.5, 1, 2, 5}, 0.1, 0.5 &}, {}, {}];

This plot is an example of domain coloring for the function f(z)  =  tan z: each point z in the domain of the function is colored according to some property of the value f(z); the property here is the value of the modulus.

Coded density plots

A coded density plot...

OnePanelPlot[{Tan},  
        CodedDensity, {0, π},  {AbsArgColor[{0, 
              5}]},  {},  {}];

This is another type  of domain coloring for the function f(z)  =  tan z: each point z in the domain of the function is colored according to the values of both the modulus and the argument of the value f(z).  As the principal argument Arg[f(z)] of f(z) varies from -π to π, the color of the point z varies from cyan to magenta; this color is mixed with varying amounts of yellow as the modulus |f(z)| varies from 0 to the maximum considered here, which is 5.  Points where the modulus is greater than 5 are plotted as white.

Here is a wider view (the code will take considerably longer to evaluate).

OnePanelPlot[{Tan},  
        CodedDensity, {0, 
          5  π},  {AbsArgColor[{0, 5}]},  {},  {PlotPoints -> 
            200}];

As you see, all the "action" is along the real axis.

A map to the Riemann Sphere

The following maps a square grid onto the Riemann sphere and then rotates the sphere.

grid = {{{Black},  {-π/2, π/2, 
              14},  {-π/2, π/2, 
              14}}};
points = 
        MapThread[{#1, ComplexPoint[#2]} &, {{RoyalBlue, SkyBlue, LightPink, 
              DeepCadmiumRed}, 
            0.93  π/
                2 {1 + I, -1 + I, -1 - I, 1 - I}}];
primitives = 
{AbsolutePointSize[5], points, 
          First[CartesianGrid[{# &}, {0, π/
                  2}, {grid}]]};

    
TwoPanelAnimation[
{{# &}, CartesianGrid, 
            static, {0, π}, {grid}, {AbsolutePointSize[5], 
              points}}, 

{{Tan}, 
RiemannSphere, 
            rotation, 
{0, 
              1.1}, 
{ColoredRiemannSphere[{Carrot, 
                  0.99}, {}, {}], 
              primitives}, {}, {PlotRegion -> {{-0.1, 
                    1.1}, {-0.25, 1.05}}}}][24];

We can see that the tan function is periodic in the real direction (the red dots come together and the blue dots come together), and undergoes a phase shift of π when traveling in the imaginary direction (the vertical circles move from one side of the sphere to the other). This is rather interesting! It is a parametrization of the sphere that is rotated from the usual longitude-latitude parametrization.

The Riemann sphere is one of the best ways to visualize periodicity!

ComplexVector animations

The next plot will be superimposed upon a background of the same argument–modulus domain coloring as before:

backplot = 
        DoShow[CodedDensity[{Tan},  {0, π},  {AbsArgColor[{0, 
                  5}, {-π,  π}]}, {}, {ImageSize -> 
                350}]];

At each point z of the domain, represent the value tan z by a vector drawn from z to z  +  tan z.  For example, the arrow in the plot below represents tan (2  +  i π/8).

OnePanelPlot[
{Tan}, 
 
        ComplexVector, 
{0, π, 
          0.4},  
{{2 + I π/8}, 
          CirclePoint[#, 3, Black, White] &}, 
{Prolog[
            First@backplot]}];

The following animation shows the behavior of  tan if we skim in the real direction just above and below the "poles" that lie on the real axis.

Clear[x]

Clear[grid1];
grid1[x_] = {x - I π/8, 
          x + I π/8};
\(\(\(frame1[
          x_] := 
OnePanelPlot[
{Tan}, 
\ 
          ComplexVector, 
{0, π, 
            0.4}, \ 
{{grid1[x]}, 
            CirclePoint[#, 3, Black, White] &}, 
{Prolog[
              First@backplot]}];\)\(
\)
    \)\)
Animate[frame1[x], {x, -3, 3, 6/31}]
SelectionMove[EvaluationNotebook[], All, GeneratedCell]
FrontEndTokenExecute["OpenCloseGroup"]; Pause[0.5];
FrontEndExecute[{FrontEnd`SelectionAnimate[200, 
          AnimationDisplayTime -> 0.1, 
          AnimationDirection -> ForwardBackward]}]

The following scans in the imaginary direction:

Clear[grid];
grid2[
          y_] = {-1.87 + I y, -1.27 + I y, I y, 1.27 + I y, 
          1.87 + I y};
\(\(\(frame2[
          y_] := 
OnePanelPlot[
{Tan}, 
\ 
          ComplexVector, 
{0, π, 
            0.4}, \ 
{{grid2[y]}, 
            CirclePoint[#, 3, Black, White] &}, 
{Prolog[
              First@backplot]}];\)\(
\)
    \)\)
Animate[frame2[y], {y, -3, 3, 6/32}]
SelectionMove[EvaluationNotebook[], All, GeneratedCell]
FrontEndTokenExecute["OpenCloseGroup"]; Pause[0.5];
FrontEndExecute[{FrontEnd`SelectionAnimate[200, 
          AnimationDisplayTime -> 0.1, 
          AnimationDirection -> ForwardBackward]}]

The following moves in a circle around the origin and shows that the origin is a critical point. The vector makes one complete rotation.

frame3[θ_] := 
OnePanelPlot[
{Tan}, 
 
          ComplexVector, 
{0, π, 
            0.4},  
{{(E^(I θ))}, 
            CirclePoint[#, 3, Black, White] &}, 
{Prolog[
              First@backplot, Gray, 
              ComplexCircle[0, 1]]}];

    
Animate[
      frame3[θ], {θ, 0, 2  π - 2  π/48, 
        2  π/48}]
SelectionMove[EvaluationNotebook[], All, GeneratedCell]
FrontEndTokenExecute["OpenCloseGroup"]; Pause[0.5];
FrontEndExecute[{FrontEnd`SelectionAnimate[200, 
          AnimationDisplayTime -> 0.1, 
          AnimationDirection -> Forward]}]

The pole z  =  π/2 is also a critical point:

frame4[θ_] := 
OnePanelPlot[
{Tan}, 
 
          ComplexVector, 
{0, π, 
            0.4},  
{{π/
                  2 + (E^(I θ))}, 
            CirclePoint[#, 3, Black, White] &}, 
{Prolog[
              First@backplot, Gray, 
              ComplexCircle[π/2, 1]]}];

    
Animate[
      frame4[θ], {θ, 0, 2  π - 2  π/48, 
        2  π/48}]
SelectionMove[EvaluationNotebook[], All, GeneratedCell]
FrontEndTokenExecute["OpenCloseGroup"]; Pause[0.5];
FrontEndExecute[{FrontEnd`SelectionAnimate[200, 
          AnimationDisplayTime -> 0.1, 
          AnimationDirection -> Forward]}]

However, the point i π/2 is not a critical point...

frame5[θ_] := 
OnePanelPlot[
{Tan}, 
 
          ComplexVector, 
{0, π, 
            0.4},  
{{I π/
                    2 + (E^(I θ))}, 
            CirclePoint[#, 3, Black, White] &}, 
{Prolog[
              First@backplot, Gray, 
              ComplexCircle[I π/2, 
                1]]}];

    
Animate[
      frame5[θ], {θ, 0, 2  π - 2  π/48, 
        2  π/48}]
SelectionMove[EvaluationNotebook[], All, GeneratedCell]
FrontEndTokenExecute["OpenCloseGroup"]; Pause[0.5];
FrontEndExecute[{FrontEnd`SelectionAnimate[200, 
          AnimationDisplayTime -> 0.1, 
          AnimationDirection -> Forward]}]

LIkewise, the point 2.5 is not a critical point. You can explore other points.

\(\(\(frame6[θ_] := 
OnePanelPlot[
{Tan}, 
\ 
          ComplexVector, 
{0, π, 
            0.4}, \ 
{{2.5 + 
                1/4  E\^\(I\ θ\)}, 
            CirclePoint[#, 3, Black, White] &}, 
{Prolog[
              First@backplot, Gray, ComplexCircle[2.5, 1/4]]}];\)\(
\)
    \)\)
Animate[
      frame6[θ], {θ, 0, 2  π - 2  π/48, 
        2  π/48}]
SelectionMove[EvaluationNotebook[], All, GeneratedCell]
FrontEndTokenExecute["OpenCloseGroup"]; Pause[0.5];
FrontEndExecute[{FrontEnd`SelectionAnimate[200, 
          AnimationDisplayTime -> 0.1, 
          AnimationDirection -> Forward]}]