# MAT 232 Chapter Three

## What are isomorphisms, homomorphisms, linear transformations?

Chapter Three takes us through a fairly abstract world of changes in vector spaces.  But underlying it all is a basic concept:

Vectors have information.  We might want only some of that information, or want to change it in some way, while getting a vector back.

Doing this consistently is the focus of this chapter.

### Motivating Examples

Let's start with some motivating examples before we try to really do more.

#### Voting

Recall the example I've done several times where we imagine 27 voters if the election this fall is between Sanders, Bloomberg, and Trump.  We have represented this as a vector.

vector([5,14,8])
 (5, 14, 8) (5, 14, 8)

We can use a basis to get the average number of votes, or ... we can just formally add up all the votes.

sum(vector([5,14,8]))
 27 27

Let's make this a little more formal.  If $S=5$, $B=14$, and $T=8$, we could make this a formula.

S = 5 B = 14 T = 8 S+B+T
 27 27

This is a nice linear equation.  If we change the numbers, we just change the numbers.

@interact def _(S = 5, B = 14, T = 8): return S+B+T

## Click to the left again to hide and once more to show the dynamic interactive window

• If we multiply all the individual votes by the same number, the final number of votes is multiplied by that number.
• If we add two smaller votes together, the total number of votes will be the sum of the totals for the smaller votes.
• Both the input and the output seem to be vectors.
@interact(layout=[['S','B','T'],['S2','B2','T2'],['constant'],['mul','add']]) def _(S = input_box(5,width=20),B = input_box(14,width=20),T = input_box(8,width=20),S2 = input_box(1,width=20),B2 = input_box(1,width=20),T2 = input_box(1,width=20),constant=input_box(2,width=20),add=False,mul=False): print 'First voter total is ',S+B+T print 'Second voter total is ',S2+B2+T2 if add and not mul: print 'Added is ', (S+B+T)+(S2+B2+T2) elif mul and not add: print 'Multiply first by a constant is', constant*(S+B+T) elif mul and add: print 'Please select just one'

## Click to the left again to hide and once more to show the dynamic interactive window

Notice that this behaves very "linearly".

#### Graphics

Imagine that you are trying to do some basic computer graphics manipulations.  Maybe you have a line or circle you want to move around... or maybe a rectangular box.

def Box(a,b,color='red'): return line([(0,0),(a,0),(a,b),(0,b),(0,0)],color=color,figsize=3,aspect_ratio=1)+point((a,b),color='green',size=20)
Box(2,1)
Box(1,2,'green')

These two boxes are nice.  Pretty clearly I've just flipped them:

Box(1,2)+Box(2,1,color='blue')+plot(x,(x,0,2),linestyle='--')

Can I flip other boxes?

@interact def _(a=1,b=2): show(Box(a,b)+Box(b,a,color='blue')+plot(x,(x,0,max(a,b)),linestyle='--'))

## Click to the left again to hide and once more to show the dynamic interactive window

Really the relationship here is $$x'=y\qquad y'=x$$ which we can think of as something more interesting: \begin{align} x' & = 0x+1y \\ y'& = 1x+0y \end{align} or $$\left(\begin{matrix} 0 & 1 \\ 1 & 0 \end{matrix}\right)$$  How about a rotation?

@interact def _(a=1,b=2): show(Box(a,b)+Box(-b,a,color='blue'))

## Click to the left again to hide and once more to show the dynamic interactive window

The same thing seems to work.  \begin{align} x' & = 0x-1y \\ y'& = 1x+0y \end{align} or $$\left(\begin{matrix} 0 & -1 \\ 1 & 0 \end{matrix}\right)$$  Really, we're just moving the corner around.  So we can think of this as taking a vector $(a,b)$ in $\mathbb{R}^2$ and just moving it to another vector in $\mathbb{R}^2$, given by the linear equations given in shorthand by the matrix.  (We can imagine more complicated ones too, but this is enough for now.)  And the actions are clearly behaving linearly in terms of the starting vector.

#### Population

Many applications have two (or more) populations that fluctuate with the other.

Boston = .1 Beverly = .9
Boston, Beverly
 (0.100000000000000, 0.900000000000000) (0.100000000000000, 0.900000000000000)

We can imagine that there is an equation saying how people move around: \begin{align} Boston & = .2*Beverly+.3*Boston \\ Beverly& = .8*Beverly+.7*Boston \end{align}

Boston, Beverly = .2*Beverly + .3*Boston, .8*Beverly + .7*Boston
Boston, Beverly
 (0.222210000000000, 0.777790000000000) (0.222210000000000, 0.777790000000000)

We can follow this for quite a while, but maybe we should change a few things.

@interact def _(Boston=100,Beverly=900,years=[1..20]): for i in range(years): Boston,Beverly = .2*Beverly + .3*Boston, .8*Beverly + .7*Boston print 'Final percentages after ',years,'years' print 'Boston:',Boston print 'Beverly:',Beverly

## Click to the left again to hide and once more to show the dynamic interactive window

Huh!  That's ... weird.

• But what if I made a mistake, and the inputs were twice as much?
• But what if I made a mistake, and there were two years of graduates to follow?

### Visualizing Linear Transformations (and other homomorphisms)

Let's see what can happen in a linear transformation. We will use the convention that $a,b,c$ are variable names for the domain, and $x,y,z$ in the codomain - it will be clear how to input them.

This first setup is taking vectors from $\mathbb{R}^2$ and sending them to $\mathbb{R}^3$.  What happens if we make the transformation have nontrivial linear relations?  Can we get every possible vector?

## Click to the left again to hide and once more to show the dynamic interactive window

The thick vectors are the original ones, the skinny ones are the "transformed" vectors.  What are the possibilities?  For instance, what of projection to the $xy$-plane, as on page 291?

## Click to the left again to hide and once more to show the dynamic interactive window

In this example, we want Smiley Guy to not just preserve his size, but also to preserve "shape", which we can guarantee by asking whether the linear map doesn't change any lengths.

We can also ask about something seemingly completely different.  Namely, can we try to see about how to analyze data with linear algebra?

Let's do an experiment.  I have fifteen multicolored dice, and I want to see how many green dice I get, on average.  Hopefully 2.5!  But what if they are weighted toward the green?  (We assume the dice are actually identical, just to avoid the tedium of rolling the dice a lot.)

my_green_rolls=[4,1,1,1,2,4,5,3,1]
list2 = [15*i for i in range(1,len(my_green_rolls)+1)]; list2
 [15, 30, 45, 60, 75, 90, 105, 120, 135] [15, 30, 45, 60, 75, 90, 105, 120, 135]
list3 = [sum(my_green_rolls[:i]) for i in range(1,len(my_green_rolls)+1)]; list3
 [4, 5, 6, 7, 9, 13, 18, 21, 22] [4, 5, 6, 7, 9, 13, 18, 21, 22]
points([(0,0)]+zip(list2,list3),figsize=5)
@interact def _(m=1/6): show(points([(0,0)]+zip(list2,list3))+plot(m*x,(x,0,list2[-1]),color='red'),figsize=5)

## Click to the left again to hide and once more to show the dynamic interactive window

Well - what slope will make the most sense?  This one seems plausible, but maybe another is better?  And this was just one simulation.

In order to answer this better, we will need to talk about lengths of vectors and angles again.

import pylab A_image = pylab.mean(pylab.imread(DATA + 'gordon_college_medium.png'), 2) @interact def svd_image(i=(20,(1..100)),display_axes=True): u,s,v = pylab.linalg.svd(A_image) A = sum(s[j]*pylab.outer(u[0:,j],v[j,0:]) for j in range(i)) g = graphics_array([matrix_plot(A),matrix_plot(A_image)]) show(g,axes=display_axes, figsize=[8,3]) pretty_print(html('<h2>Compressed using %s eigenvalues</h2>'%i))

display_axes

## Click to the left again to hide and once more to show the dynamic interactive window

This example shows us that image compression also can happen using orthogonal vectors, though we won't be able to see how this kind of thing might be approached until the last day of lecture.

Data analysis uses similar tools as well... and so forth!