Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168732
Image: ubuntu2004

6/6/11 8am

Graphing on the Complex Plane: Using Sage to Learn Math

This will be an example of using Sage to explore some mathematics.

 

Consider the point 1+i31+i\sqrt{3} on the complex plane.  This is a very simple Sage picture.

P=(1,sqrt(3)) # This is a tuple -- in this case coordinates. point(P,color="red").show() # Now a graphics command.

Let's add a little more to the construction of the picture.  Get all quadrants, and add a label to the point.

maxX=3 # use this to control logical size of axes P=(1,sqrt(3)) epsilon=vector((.25,0)) Ppt=point(P,color="red") Ptex = "$"+repr(latex(P[0]+I*P[1]))+"$" # put coordinates into LaTeX Ptext=text(Ptex, vector(P)+epsilon, horizontal_alignment='left') show(Ppt+Ptext, aspect_ratio=1,xmin=-maxX, xmax=maxX, ymin=-maxX, ymax=maxX)

Consider writing PP using polar coordinates.  Assume that vector PP is at an angle of θ\theta from the real axis.   PP is at $r (\cos \theta + i \, \sin \theta).

H=line([(0,0),P], color='red', linestyle="--") C=line([(0,0),(P[0],0)], color="blue", thickness=3) S=line([(P[0],0),P], color='green', thickness=2) Ptext=text("$P$", vector(P)+epsilon, horizontal_alignment='left') thetatext=text("$\theta$", (.3,.2), horizontal_alignment='left') show(Ppt+H+C+S+Ptext+thetatext, aspect_ratio=1, xmin=-maxX, xmax=maxX, ymin=-maxX, ymax=maxX)

Consider a parametric curve on the complex plane defined by the function f(t)=cost+isintf(t)=\cos t + i \, \sin t.  This is just a unit circle, the set of all complex points that are distance 1 from the origin.

var('t') fplot=parametric_plot((cos(t),sin(t)),(t,0,2*pi), color='red') show(fplot, aspect_ratio=1, xmin=-maxX, xmax=maxX, ymin=-maxX, ymax=maxX)

Now look at f(t)f'(t).

f(t)=cost+isintf(t)=\cos t + i \, \sin t
f(t)=sint+icostf'(t)=-\sin t + i \, \cos t
f(t)=i2sint+icostf'(t)=i^2 \,\sin t + i \, \cos t
f(t)=i(isint+cost)f'(t)=i(i\, \sin t + \cos t)
f(t)=i(cost+isint)=if(t)f'(t)=i(\cos t + i \, \sin t)=i \, f(t)

Recall when y=kyy'=ky, y=Dekty=De^{kt} where D=y(0)D=y(0).
This means we can say f(t)=eitf(t)=e^{it}.

Yes, eiθ=cosθ+isinθe^{i\theta}=\cos \theta + i\,\sin \theta.

exp(I*pi)
-1

Looking at Functions on Complex Numbers

A function from the complex plane to the complex plane has a four dimensional feel. Color can help us get a better sense of what is going on.

Each point (z=reiθz=re^{i\theta}) on the complex plane is assigned a color where the "hue" is a fucntion of the angle (θ\theta) and the "lightness" is based on the distance from the origin (rr). (See wikipedia on HSV color.)

circ=circle((0,0), 1, color='white', linestyle="dashed") base=complex_plot(lambda z: z,[-4,4],[-4,4]) # the identity function html.table([[base,base+circ], ["identity", "with unit circle"]])
identity with unit circle

Consider a map that takes zz to z+1z+1.  What do you see when you compare the two figures below:

plusOne=complex_plot(lambda z:z+1, [-4,4],[-4,4]) html.table([[base,plusOne], ["identity", "$z \mapsto z+1$"]])
identity z \mapsto z+1

Now what happens when you multiply a complex number by ii?

  zizz \mapsto i \cdot z

timesI=complex_plot(lambda z:I*z, [-4,4],[-4,4]) html.table([[base,timesI], ["identity", "$z \mapsto i \cdot z$"]])
identity z \mapsto i \cdot z

Not all maps are transformations.  How can you see from the picture that zz2z \mapsto z^2 is not a transformation?

squared=complex_plot(lambda z: z^2, [-4,4],[-4,4]) html.table([[base,squared], ["identity", "$z \mapsto z^2$"]])
identity z \mapsto z^2

Something to Consider: What can you say about zsin(z)z \mapsto \sin(z)?

I leave this for you to explore. Note that Sage is not your only tool. A pencil and pad with eiθ=cosθ+isinθe^{i\theta}=\cos \theta + i\,\sin \theta is a good place to start.
Hint: Recall that hyperbolic trig functions are defined by cosh(t)=et+et2and sinh(t)=etet2\cosh(t)=\frac{e^t+e^{-t}}{2} \qquad \text{and } \qquad \sinh(t)=\frac{e^t-e^{-t}}{2}
In a similar manner, you can express sin(t)\sin(t) in terms of eite^{it}.

sinz=complex_plot(lambda z: sin(z), [-4,4],[-4,4]) html.table([[base,sinz], ["identity", "$z \mapsto \sin(z)$"]])
identity z \mapsto \sin(z)

More Transformations of the Complex Plane

Consider reflecting over the real (xx) axis.

conj=complex_plot(lambda z: conjugate(z), [-4,4],[-4,4]) html.table([[base,conj], ["identity", "$z \mapsto \overline{z}$"]])
identity z \mapsto \overline{z}
invert=complex_plot(lambda z: 1/conjugate(z), [-4,4],[-4,4]) html.table([[base+circ,invert+circ], ["identity", "$z \mapsto (\overline{z})^{-1}$"]])
identity z \mapsto (\overline{z})^{-1}
pre=[CC(2+I*j) for j in srange(-4,4,.1)] preP=sum([z.plot(color="green") for z in pre]) image=[1/z.conjugate() for z in pre] imageP=sum([z.plot(color="red") for z in image]) circP=circle((0,0), 1, color='black') show(preP+circP+imageP, aspect_ratio=1, xmin=-maxX, xmax=maxX, ymin=-maxX, ymax=maxX)