Transformations in the plane

Ivan Cnop
Vrije universiteit Brussel
icnop@vub.ac.be

Recall that 
//MatrixForm
will convert a double list into a traditional rectangular matrix and
//ColumnForm
will convert a list or double list into a column.

Images of basis vectors

Write all vertices of the unit square:

\(\(begin = 
        Flatten[Union[
			{Table[{0, 1 - j}, {j, 0, 1}], 
              Table[{1, j}, {j, 0, 1}]}], 1];\)\)

basisBlock = Polygon[begin]

\(Show[Graphics[{GrayLevel[ .5], basisBlock}]
, 
      AspectRatio -> Automatic
	, Axes -> Automatic
	, 
      PlotRange -> {{\(-3\), 3}, {\(-3\), 3}}]\)

What does a matrix do with such a square?

A=(({{1, -0.2}, {- .5, .9}}))

image[{x_, y_}] := A . {x, y}

\(Show[{Graphics[{GrayLevel[ .5], basisBlock}], 
        Graphics[{Hue[0], Polygon[Map[image, begin]]}]}
, 
      AspectRatio -> Automatic
	, Axes -> Automatic
	, 
      PlotRange -> {{\(-3\), 3}, {\(-3\), 3}}
	]\)

The images of the basis vectors are precisely the columns of the matrix A:

image[{1, 0}] // ColumnForm

image[{0, 1}] // ColumnForm

A // MatrixForm

For later use we include a parameter in the matrix

Clear[images]

\(\(\(images[
        a_] := {{GrayLevel[ .5], basisBlock}, {Hue[0], 
          Polygon[Map[A . # &, begin]]}}\)\(
\)
    \)\)

Try this again

A=(({{1, 1.7}, {- .5, .9}}))

image[{x_, y_}] := A . {x, y}

\(Show[{Graphics[{GrayLevel[ .5], basisBlock}], 
        Graphics[{Hue[0], Polygon[Map[image, begin]]}]}
, 
      AspectRatio -> Automatic
	, Axes -> Automatic
	, 
      PlotRange -> {{\(-3\), 3}, {\(-3\), 3}}
	]\)

image[{1, 0}] // ColumnForm

image[{0, 1}] // ColumnForm

A // MatrixForm

Input your own matrix

A=(({{◼, ◼}, {◼, ◼}}))

Special cases

Vertical projection

a =. 
A=(({{1, 0}, {0, a}}))

Does not preserve area (unless a= 1 or -1):

Det[A]

Animate the action for different values of a (best is a circular animation):

\(Do[Show[Graphics[images[a]]
, AspectRatio -> Automatic
	, 
        Axes -> Automatic
	, 
        PlotRange -> {{\(-3\), 3}, {\(-3\), 3}}]
, {a, 1, 
        0, \(- .1\)}]\)

Horizontal projection

a =. 
A=(({{a, 0}, {0, 1}}))

Does not preserve area (unless a= 1 or -1):

Det[A]

Animate the action for different values of a (best is a circular animation):

\(Do[Show[Graphics[images[a]]
, AspectRatio -> Automatic
	, 
        Axes -> Automatic
	, 
        PlotRange -> {{\(-3\), 3}, {\(-3\), 3}}]
, {a, 1, 
        0, \(- .1\)}]\)

Homotetical image

a =. 
A=(({{a, 0}, {0, a}}))

Does not preserve area (unless a= 1 or -1):

Det[A]

Animate the action for different values of a (best is a circular animation):

\(Do[Show[Graphics[images[a]]
, AspectRatio -> Automatic
	, 
        Axes -> Automatic
	, 
        PlotRange -> {{\(-3\), 3}, {\(-3\), 3}}]
, {a, 
        1, \(- .8\), \(- .2\)}]\)

Reflection about the y-axis .

a =. 
A=(({{-1, 0}, {0, 1}}))

Does preserve area:

Det[A]

\(Do[Show[Graphics[images[a]]
, AspectRatio -> Automatic
	, 
        Axes -> Automatic
	, 
        PlotRange -> {{\(-3\), 3}, {\(-3\), 3}}]
, {a, 1, 
        1,  .1}]\)

Exercise

Repeat this for a reflection about the x-axis

Schear

a =. 
A=(({{1, 0}, {a, 1}}))

Animate the action for different values of a (best is a circular animation):

\(Do[Show[Graphics[images[a]]
, AspectRatio -> Automatic
	, 
        Axes -> Automatic
	, 
        PlotRange -> {{\(-3\), 3}, {\(-3\), 3}}]
, {a, 0, 
        1,  .1}]\)

They do preserve area:

Det[A]

Rotation

a =. 
A=(({{Cos[a], -Sin[a]}, {Sin[a], Cos[a]}}))

Does preserve area:

Det[A]

Simplify[%] == 1

Animate the action for different values of a (best is a circular animation):

\(Do[Show[Graphics[images[a]]
, AspectRatio -> Automatic
	, 
        Axes -> Automatic
	, 
        PlotRange -> {{\(-3\), 3}, {\(-3\), 3}}]
, {a, 0, 2  Pi, 
        Pi/12}]\)

A marketing problem

Problem

Suppose computer manufacturer  X  loses  7% of his clients to  computer manufacturer  Y   each year, and  5  %  of computer   Y   users convert to  X  computers .

Modeling

Horizontal axis stands for computer  X users  and vertical axis counts computer Y users. 
Here is the matrix that models the transition over a single year.

A=(({{.93, .05}, {.07, .95}}))

A // MatrixForm

image[{x_, y_}] := A . {x, y}

image[pts_List] := Map[image, pts]

figure[j_] := Nest[image, begin, j]

figure[3]

\(Do[Show[Graphics[{Hue[j/20], Polygon[figure[j]]}]
	, 
        AspectRatio -> Automatic
	, Axes -> Automatic
	, 
        PlotRange -> {{\(-3\), 3}, {\(-3\), 3}}]
, {j, 0, 12}]\)

Conclusion: even in the cases where we start from either
100% HP (the first basis vector) or in the case of 100% Dell (the second basis vector)
the situation will evolve to a stable proportion of about 40 % HP, 60 % Dell. 
Let us zoom in to see the exact value:

\(Do[Show[Graphics[{Hue[j/20], Polygon[figure[j]]}]
	, 
        AspectRatio -> Automatic
	, Axes -> Automatic, 
        AxesLabel -> {HP, Dell}
	, 
        PlotRange -> {{\(-1.3\), 1.3}, {\(-1.3\), 1.3}}]
, {j, 0, 
        16}]\)

From a starting point in the middle 50 - 50 market share

A . { .5,  .5}

A . %

A . %

A . %

Repeating the application of a matrix many times is written in shorthand  using  NestList  and  #& :

NestList[A . # &, { .5,  .5}, 100];

ListPlot[%,  PlotRange ->  {{ .4,  .5}, { .5,  .6}},  
      AspectRatio -> Automatic]

Find the value graphically and compare with the final value from the   NestList   line

Nest[A . # &, { .5,  .5}, 100]

Remark: convergence to this value is rather fast (exponentially in the number of years)

Even from the extreme situation

NestList[A . # &, {0, 1}, 100];

ListPlot[%, PlotRange -> {{0, 1}, {0, 1}}, 
      AspectRatio -> Automatic]

For later use we compute

Eigenvalues[A]

Eigenvectors[A]

Load a package

<< Graphics`Arrow`

and make shure your arrows start from the origin:

arrow[{a_, b_}] := Arrow[{0, 0}, {a, b}]

Here is the last figure again:

\(Show[Graphics[{Hue[16/20], Polygon[figure[16]]}]
	, 
      AspectRatio -> Automatic
	, Axes -> Automatic, 
      AxesLabel -> {HP, Dell}
	, 
      PlotRange -> {{\(-1.3\), 1.3}, {\(-1.3\), 1.3}}]\)

We see that compression is tending to one arrow and that it has happened in the direction of the other arrow

\(Show[
      Graphics[Map[arrow, \(-Eigenvectors[A]\)]
, 
        AspectRatio -> Automatic
, 
        Axes -> Automatic
, 
        AxesLabel -> {HP, Dell}
	, 
        PlotRange -> {{\(-1.3\), 1.3}, {\(-1.3\), 1.3}}]]\)

The first vector is a fixed point (eigenvalue = 1)

A . First[Eigenvectors[A]]

% == First[Eigenvectors[A]]

Exercise: work this problem with slightly different percentages

e.g. 4  and   12  %

Epilogue: action of a matrix on directions

Show[Graphics[
    Table[{Hue[x/(2π)],arrow[{Cos[x], Sin[x]}]},
          {x, 0, 2 π, .3}]
],AspectRatio->Automatic
,Axes->Automatic, PlotRange -> All]

Applying A once to these arrows gives

Table[A . {Cos[x], Sin[x]}, {x, 0, 2 π,  .3}];

Show[Graphics[
    Map[arrow,%]
],AspectRatio->Automatic
,Axes->Automatic, PlotRange -> All]

Applying A twice to these arrows gives

Table[A . A . {Cos[x], Sin[x]}, {x, 0, 2 π,  .3}];

Show[Graphics[
    Map[arrow,%]
],AspectRatio->Automatic
,Axes->Automatic, PlotRange -> All]