(********************************************************
 *                                                      *
 *  Load Color Package, Reset Variables and Arrays      *
 *                                                      * 
 *******************************************************)
Needs["Graphics`Colors`"];

ComplexPolygon[]:=
Module[{z1,NewPolygonlist,NewPolygonlist1,
NewPolygonlist2,t,x,y,z,a,b,Placeholder,Ticklist,Ticklist1},

(***************************************************************
 *                                                             *
 *  Prompts user to set z1 to a desired value. Remember,       *
 * Mathematica notation for imaginary number i is I.           *
 *                                                             * 
 *                                                             *
 ***************************************************************)

statement = AForcedInput["Enter a complex number.\nRemember: 
   \nMathematica notation for the imaginary number `i' is I."];

 
 AForcedInput[x_]:=
Module[{statement,theinput,keepgoing},
statement=x;
keepgoing=True;
While[keepgoing==True,
(theinput = Input[statement];
If[(theinput===Null)||(NumberQ[theinput]=!=True)
 ,,keepgoing=False];)];
theinput];
 
z1=statement;
 
(****************************************************************
 *                                                              *
 *   Below is a library of polygons. The ordered pairs          *
 *    are the vertices of the polygons. Set Polygonlist         * 
 *    to one of the names of the polygons.                      *
 *                                                              *
 ***************************************************************)

isoscelesrttriangle    = {{2,0},{2,2},{0,2}}; 
rectangle1         = {{0,0},{0,-3},{-4,-3},{-4,0}};
thirtysixtyninetytriangle = {{0,0},{1,0},{1,Sqrt[3]//N}};
square1         = {{2,0},{4,2},{2,4},{0,2}};
square2           = {{0,-4},{0,-2},{2,-2},{2,-4}};
quadrilateral    = {{1,7},{-3,5},{-2,-2},{0,-3}}; 

(********************************************************
 *                                                      *
 *  Prompts user to choose a polygon from library by    *
 *  entering the corresponding number                   *
 *                                                      * 
 *                                                      *
 *******************************************************)
Clear[ForcedInput,statement];

Off[Part::pspec];

Placeholder={isoscelesrttriangle,rectangle1,
thirtysixtyninetytriangle,square1,square2,quadrilateral};

statement = Placeholder[[ForcedInput["Enter the NUMBER of 
the polygon you want:\n1- Isosceles Right Triangle 
\n2- Rectangle \n3- 30-60-90 Triangle \n4- Square
 \n5- Another Square \n6- Quadrilateral "] ]];
 
  ForcedInput[x_]:=
Module[{statement,theinput,keepgoing},
statement=x;
keepgoing=True;
While[keepgoing==True,
(theinput = Input[statement];
If[(theinput< 1)||(theinput>6)
 ,,keepgoing=False];)];
theinput];

 
 Polygonlist = statement;
(*******************************************************************
 *                                                                 *
 *   The 3 Do loops below assign the real and imaginary            *
 *   parts of the complex numbers that are the vertices            * 
 *   of the polygon  to a complex number z[i]=x[i]+Iy[i]           *
 *   where i runs from 1 to the number of vertices                 * 
 *   of the polygon.                                               *
 *                                                                 *
 *******************************************************************)




Do[x[i] =Polygonlist[[i,1]],{i,1,Length[Polygonlist]}];
Do[y[i] =Polygonlist[[i,2]],{i,1,Length[Polygonlist]}];
Do[z[i]= x[i] + I y[i],{i,1,Length[Polygonlist]}];

(********************************************************
 *                                                      *
 *   The remaining Do loops translate and rotate the    *
 *   polygon through multiplication by z1, and input    * 
 *   the vertices of the resulting similar polygon      *
 *   into NewPolygonlist.                               *                                      *
 *                                                      *
 *******************************************************)

NewPolygonlist1 = {};
Do[NewPolygonlist2 = Re[z1 z[i]];
   NewPolygonlist1 = Append[NewPolygonlist1,NewPolygonlist2],
   {i,1,Length[Polygonlist]}];
   
Clear[NewPolygonlist2];
   
Do[NewPolygonlist2 = Im[z1 z[i]];
   NewPolygonlist1 = Append[NewPolygonlist1,NewPolygonlist2],
   {i,1,Length[Polygonlist]}];

t = (Length[NewPolygonlist1])/2;   

NewPolygonlist = {};
Clear[NewPolygonlist2];

Do[AppendTo[NewPolygonlist,NewPolygonlist1[[i]]];
   AppendTo[NewPolygonlist,NewPolygonlist1[[i + t]]],
   				{i,1,t}];  


NewPolygonlist = Partition[NewPolygonlist,2];

(********************************************************
 *                                                      *
 *       RangeVariable sets the limits of the axes      *                                      
 *                                                      *
 *******************************************************)
			 

RangeVariable = N[Max[Abs[{{NewPolygonlist},{Polygonlist}}]]];



(********************************************************
 *                                                      *
 *       Leftplot and rightplot are the plots of the    *                                      
 *       old and new polygons.                          *
 *                                                      * 
 *******************************************************)

leftplot = Show[Graphics
		 [{RGBColor[0.020005,0.719993,0.799997],Polygon[Polygonlist]}],
                AxesLabel->{"x","iy"},    
				Axes->True,
				AxesOrigin->{0,0},
				Ticks->Automatic,
				
				GridLines->Automatic,
			 PlotRange->
				{{-RangeVariable,RangeVariable},
				{-RangeVariable,RangeVariable}},
				AspectRatio->Automatic,
		        DisplayFunction->Identity];

rightplot = Show[Graphics
		 [{RGBColor[1.,0.078402,0.576495],Polygon[NewPolygonlist]}],
                AxesLabel->{"x","iy"},    
					Axes->True,
				AxesOrigin->{0,0},
				Ticks->Automatic,
				GridLines->Automatic,
			 PlotRange->
				{{-RangeVariable,RangeVariable},
				{-RangeVariable,RangeVariable}},
				AspectRatio->Automatic,
		        DisplayFunction->Identity];
     
		        
		        Show[GraphicsArray[{{leftplot,rightplot}}]]
		        ]

Rotations of Polygons in the Complex Plane

By Gene Bild
 University High School, Urbana Il.

BRIEF DESCRIPTION
This Mathematica  notebook contains a library of polygons in the complex plane.  You will input a complex number z of your choosing and then pick a polygon from the library.  The notebook first displays the polygon, and then displays the polygon after it has been rotated through the argument of z and had its size dilated by the absolute value of z.  In otherwords, the points in the complex plane that make up the polygon are all multiplied by z.

If you have never done a Mathematica  notebook before, or have forgotten how to run a notebook, use your mouse to position your cursor just above the harpoon-like symbol in the right margin and click twice very fast.

You have just opened a sub-cell by double clicking.  Mathematica notebooks have a hierarchy based on cells, with top cells visible, and sub-cells lurking unseen beneath the top cells.  One reason this notebook does this is to give you answers and hints to the exercises.

You will also have to activate "Input Cells" to run the program.  To do this, you will highlight the  bracket in the right margin of the screen by positioning the cursor inside the bracket and clicking the mouse once, and then hitting the ENTER key to the right of the numeric keypad on your keyboard.  The only input cell you need to deal with in this notebook is ComplexPolygon[].

Here is a practice input cell for you.  It will draw an artistic interpretation of a black hole.  Highlight the bracket to the right of the boldfaced text below and then hit ENTER.

Plot3D[ 1 - (( 12 Cos [x^2 + y^2])/(x^2 + y^2)),
		{x, -3,3},{y, -3,3},ViewPoint->{3.333, 0.085, 0.580},
		PlotRange->{-60,13},PlotPoints->50,Axes->False ]

REVIEW OF PREVIOUS NOTEBOOKS ON THE GEOMETRY OF THE COMPLEX PLANE
Double-click the harpoon to see

A complex number  z = a + ib can be graphed on a Cartesian plane with horizontal axis labelled x representing the real line, and the vertical axis labelled iy representing multiples of i.  Then z has coordinates (a, b), where a is the real part of z, and b is the imaginary part of z.

Geometrically, the absolute value, or modulus, of z is its distance from the origin in the complex plane, and the argument of z is the angle measured in a counter-clockwise direction from the positive real axis to a ray which runs from the origin to z.

When complex numbers z¡  and z™  are multiplied, the modulus of the product is the product of the modulii of z¡  and z™™™™ , while the argument of the product is the sum  of the arguments of z¡  and z™ .

Say L is a line in the complex plane, so the  points of L are complex numbers and z¡  is the midpoint of L.  Then if every complex number  on L is multiplied by z, the result is a new line, whose midpoint is the product zz¡ .  Do you remember why?

Double click the harpoon for the answer.

The arguments of every complex number on L are increased by the argument of z, so linearity is preserved.  The midpoint of a line has coordinates x =  (x¡  + x™ )/2 and y = (y¡  + y™ )/2, where  x¡¡  + i y¡  and x™  + i y™  are the endpoints of L. 
Since x + i y = z ((x¡  + x™ )/2 + i (y¡  + y™ )/2),  and is equidistant from  x¡¡  + i y¡  and x™  + i y™   (use the distance formula if you want to verify this), x + i y is the midpoint of the new line.

GEOMETRIC INTERPRETATION OF POLYGONAL MULTIPLICATION IN THE COMPLEX PLANE
Double-click the harpoon to see

Not only are linearity and midpoints of lines preserved under complex multiplication, but polygons are mapped to similar  polygons.  For example, say z = -3i. The argument of z is 270 degrees, or 3/2 Pi in radian measure, and the modulus of z is 3.  If every number  in the complex plane that is interior to the square is multiplied by z, the resulting product will be a square with side length 3 times the original, and a position that is a rotation of 270 degrees from the original square.

This notebook contains two squares.  Double-click the harpoon to see the first one before and after multiplication by -3I.

BEFORE      AFTER

Double-click the harpoon to see the second square multiplied by -3I.

BEFORE      AFTER

Now try running the notebook.  Scroll down to the cell near the bottom which contains the text "ComplexPolygon[ ]".  This is a copy of the input cell.  Activate the input cell by highlighting the bracket to its left with the mouse and hitting the ENTER key.  An input window will ask you for a compex number, enter -3I.  When prompted for a polygon, choose one of the two squares by number, either 4 or 5.

Every time you want to multiply a polygon by a complex number, you will have to activate a input cell.  If you enter a blank character, or a non-numeric value in the first input window, or anything other than the six integer values corresponding to the six polygons in the second input window, the input window will return to give you another chance.  There is an input cell in every exercise in the exercise bank.

POLYGON LIBRARY
Double click the harpoon to learn about the  six polygons available for your use

This notebook contains six polygons.  The first is an isoscles right triangle, with vertices at (2,0), (2,2) and (0,2).  The input window knows it as 1.  Double-click the harpoon to see it.

The second polygon is a rectangle with vertices at (0,0), (0,-3),  (-4,-3), and (-4,0).  The input window knows it as 2.  Double-click the harpoon to see it.

The third polygon is a 30-60-90 triangle, with vertices at (1,0), (0,0), and (1,Sqrt[3]).  The input window knows it as 3.  Double-click the harpoon to see it.

The fourth polygon is a square with vertices at (2,0),  (4,2),  (2,4),  and (0,2).  The input window knows it as 4.  Double-click the harpoon to see it.

The fifth polygon is another square, with vertices at (0,-4),  (0,-2),  (2,-2),  and (2,-4).  The input window knows it as 5.  Double-click the harpoon to see it.

The sixth and last polygon is a quadrilateral, with vertices at (1,7),  (-3,5),  (-2,-2),  and (0,-3).  The input window knows it as 6.  Double-click the harpoon to see it.

HINTS FOR ENTERING NUMBERS IN Mathematica  SYNTAX
Double-click the harpoon for hints

When entering a complex number at the input window, remember: 
			  *Mathematica  uses I (capital i) for imaginary number i.
			  *Parenthesis ( ) are for grouping, square brackets [ ] and curly 
			   brackets 	{ } have special meanings for Mathematica .

*The square root of x can be entered as Sqrt[x] or x^(1/2), and 
     the nth root of x can be entered as x^(1/n).

*Mathematica is case-sensitive, that is, it distinguishes between
     capital and lower-case letters.   This means you must  capitalize 			
     Pi, Cos, Sin, Sqrt, and other Mathematica  expressions.

*Functions Cos[x],  Sin[x] and Exp[x] are recognised by  
			   Mathematica  and can be used to enter a complex number into 			          
			   the input window, so 3(1/Sqrt[2] + I/Sqrt[2]), 
			   3(Cos[Pi/4] + I Sin[Pi/4]) and 3 Exp[I Pi/4] all represent the same   			  
			    number.

A INPUT CELL IS JUST BELOW
THIS CELL
Double-click the harpoon for help in running input cell

Use the mouse to position the cursor inside the bracket to the right of the words "ComplexPolygon[ ]."  Then hit the ENTER key to the right of the numeric keypad.

ComplexPolygon[ ]

SUGGESTION:
You might see what happens when you multiply one of the polygons by a  positive or negative real number or by some multiple of positive or negative i.

EXERCISE BANK
Double-click the harpoon for exercises

In the following exercises, you will be asked to find a number that will rotate and dilate one of the six polygons mentioned above into a specified polygon.  When you solve an exercise, scroll up to the input cell and check your solution.  Hints and answers are provided.

EXERCISE 1
Double-click the harpoon to see

Rotate the rectangle so each edge doubles in size and the vertices become (0,0), (0,6), (8,6), and (8,0).  Double click the harpoon at the right to see the plot.

USE THE INPUT CELL BELOW TO CHECK YOUR ANSWER

ComplexPolygon[ ]

Double click the harpoon at the right for a hint

How many degrees (positive radian measure) did the rectangle rotate?  This tells you something about the argument of the number you want.

Double click the harpoon at the right for the answer

The answer is -2, since Arg[-2] = Pi radians, and Abs[-2] = 2.

EXERCISE 2
Double-click the harpoon to see

Rotate the isosceles right triangle so each edge doubles in size and the vertices become (-4,0),  (-4,4),  and  (0,4).  Double click the harpoon to see the plot.

USE THE INPUT CELL BELOW TO CHECK YOUR ANSWER

ComplexPolygon[ ]

Double click the harpoon for a hint

How many degrees (positive radian measure) did the rectangle rotate?  This tells you something about the argument of the number you want.  And what does the doubling in edge size tell you about the modulus of the number you want?

Double click for the answer

The answer is 2 I, since Arg[2 I] = Pi/2 radians, and Abs[2 I] = 2.

EXERCISE 3
Double-click the harpoon to see

Rotate the 30-60-90 degree triangle so the size remains the same, but the hypotenuse lies on the negative real axis.  Double click the harpoon to see the plot.

USE THE INPUT CELL BELOW TO CHECK YOUR ANSWER

ComplexPolygon[ ]

Double click the harpoon for a hint

Before rotation the hypotenuse makes an angle of Pi/3 radians with the positive real axis.  After rotation the hypotenuse makes an angle of Pi radians with the positive real axis.  The size  of the triangle does not change, so you want a number with modulus 1.  The angle of rotation tells you what the argument should be.

Double click for the answer

-1/2 + I (Sqrt[3]/2)

EXERCISE 4
Double-click the harpoon to see

Rotate square1 (enter 4 at input window) so it maps to the square with vertices (1, 0),  (2, -1), (1, -2), and (0, -1).  Double click the harpoon at the right to see the plot.

USE THE INPUT CELL BELOW TO CHECK YOUR ANSWER

ComplexPolygon[ ]

Double click the harpoon at the right for a hint

Compare the edge length of the original square to the edge length of the rotated square.  This tells you something about the modulus of the number you want.

Double click the harpoon at the right for the answer

The answer is -I/2,whose argument is 3/2 Pi and whose modulus is 1/2.

EXERCISE 5
Double-click the harpoon to see

Rotate square2 (enter 5 at input window) so it maps to the square with vertices (4, 0),  (8, 0), (8, 4), and (4, 4).  Double click the harpoon at the right to see the plot.

USE THE INPUT CELL BELOW TO CHECK YOUR ANSWER

ComplexPolygon[ ]

Double click the harpoon at the right for a hint

One edge of the square is always on one of the axes.  Through what angle is it rotated?

Double click the harpoon at the right for the answer

The answer is 2 I, whose argument is 1/2 Pi and whose modulus is 2.

EXERCISE 6
Double-click the harpoon to see

Rotate square2 (enter 5 at input window) so it maps to the square with vertices (-1, 0),  (-1, -1), (-2, -1), and (-2, 0).  Double click the harpoon at the right to see the plot.

USE THE INPUT CELL BELOW TO CHECK YOUR ANSWER

ComplexPolygon[ ]

Double click the harpoon at the right for a hint

One edge of the square is always on one of the axes.  Through what angle is it rotated?  Since the edge size is cut in half, what is the modulus of the number you want?

Double click the harpoon at the right for the answer

The answer is -1/2 I, whose argument is 3/2 Pi and whose modulus is 1/2.

EXERCISE 7
Double-click the harpoon to see

Rotate the isosceles right triangle so its size remains the same,  but the positive imaginary axis is the perpendicular bisector of the hypotenuse.  Double click the harpoon at the right to see the plot.

USE THE INPUT CELL BELOW TO CHECK YOUR ANSWER

ComplexPolygon[ ]

Double click the harpoon at the right for a hint

What angle does the hypotenuse make with the positive real axis before and after rotation?

Double click the harpoon at the right for the answer

The answer is 1/Sqrt[2] + I/Sqrt[2], whose argument is Pi/4 and whose modulus is 1.

EXERCISE 8
Double-click the harpoon to see

As in EXERCISE 7 above, rotate the isosceles right triangle so the positive imaginary axis is the perpendicular bisector of the hypotenuse, but the hypotenuse will be at a height of exactly 1 unit.   Double click the harpoon at the right to see the plot.

USE THE INPUT CELL BELOW TO CHECK YOUR ANSWER

ComplexPolygon[ ]

Double click the harpoon at the right for a hint

The angle of rotation will be the same as in EXERCISE 7, 	but the size will change.  Use knowledge of right triangles to determine the lengths of the hypotenuses in the original and rotated triangles.

Double click the harpoon at the right for the answer

The answer is 1/2 + I/2, whose argument is Pi/4 and whose modulus is 1/Sqrt[2].  You can figure this out by noting the length of the hypotenuse of the original triangle is 2 Sqrt[2] and the length of the hypotenuse of the rotated triangle is 2.  
Since (1/Sqrt[2]) (2 Sqrt[2]) = 2, the modulus of the answer is 1/Sqrt[2].

EXERCISE 9
Double-click the harpoon to see

Take the result of EXERCISE 7 and map it to the result of EXERCISE 8. This means you assume isosceles right triangle has already been rotated so the positive imaginary axis is the perpendicular bisector of the hypotenuse.  You need to "pull it down" so the hypotenuse is 1 unit above the origin.   Double click the harpoon at the right to see the plot.

USE THE INPUT CELL BELOW TO CHECK YOUR ANSWER

ComplexPolygon[ ]

Double click the harpoon at the right for a hint

Let z¡  = 1/Sqrt[2] + I/Sqrt[2], and let z™  = 1/2 + I/2.  z¡  rotates the original triangle to the initial position for EXERCISE 9, and z™  rotates the original triangle to the end position for EXERCISE 9.  Now say z is some complex number in the isosceles right triangle before any rotations.  Multiplication by z¡  maps z to zz¡  and multiplication by z™  maps z to zz™. .  What number would you multiply by to map zz¡  to 
zz™  ?

Double click the harpoon at the right for the answer

The answer is 1/Sqrt[2], which is z™  / z¡ .

COMING ATTRACTIONS
Double-click the harpoon to see

The next notebook in the series will be on mappings that do not
take polygons to similar polygons, but to other polygons.  Learn how to map a hyperbola to a straight line, and map the interior of a disk to its exterior.  For those of you who liked EXERCISE 9, the next notebook also discusses decomposing a mapping into a series of steps.