experimental mathematics 25 august 2011 linear transformations and ranks
TRANSCRIPT
Experimental Mathematics
25 August 2011
Linear Transformations and Ranks
Recall from Linear Algebra I:
Let V and W be vector spaces. A linear transformation
WVT : is a function with the following properties:
VvuvTuTvuTi , allfor )()()( )(
R cVvvcTcvTii , allfor )()( )(
Basic example of a linear transformation
Axx
RR
A
)(
bygiven
:
nnsformatiolinear tra a determines matrix An
T
T
nmmn
Visualizing Vectors
To visualize linear transformations, we need to be able to visualize vectors first. Try the following in Sage:
v = vector([1,2])w = vector([4,1])plot(v) + plot(w) + plot(v - w)
The Sage function on the next slide plots the vectors in a list L in different colors (it is not necessary to understand the details of the function, we just use it as a tool).
Vector Plotting Function
def vector_plotter(vec_list, points=False): l = float(len(vec_list)) pic = Graphics() for i, v in enumerate(vec_list): if points: pic += point(v,hue=(i/l)) else: pic += plot(v,hue=(i/l)) return pic
Example1
L=[vector([1,0]),vector([0,1]),vector([-1,0]),vector([0,-1])]vector_plotter(L)
Example 2
L=[vector([1,0]),vector([0.75,0.25]),vector([0.5,0.5]),vector([0.25,0.75])]vector_plotter(L,points=true)
Note: points=true has the effect that vectors are represented by points instead of arrows.
Visualization of Linear Transformations
We will visualize 2D linear transformations by applying them to vectors in the plot on the following slide.
Example 3
L = [vector([cos(i),sin(i)]) for i in srange(0,2*pi,2*pi/20,universe=RDF)]vector_plotter(L)
Note: srange(a,b,c) returns the list of numbers in [a,b) starting with a and with step size c. universe=RDF makes sure the number are in double precision floating point format.
Problem 1
Modify Example 3 so that an ellipse with axes of length 2 and 3 is shown.
The map FunctionPython has a built in map function which can be used to apply a function f to all entries of a list L. Syntax: map(f,L)
Examples:
L=range(5)def f(x): return x^2map(f,L) # output [0,1,4,9,16]
Multiply all vectors in a list with a matrix:L=[vector([1,0]),vector([0,1])]M=matrix([[3,5],[1,2]])def f(v): return M*vmap(f,L)
Problem 2
• Let L be the list of vectors from Example 3. Use the map function to multiply all vectors in L with the matrix [[1,0.3],[0.3,0.8]] and plot the resulting list using the vector_plotter function.
• Try this for other matrices. What are the possible “shapes” that can arise?
Recall from Linear Algebra I:
with vectorsall ofset of kernel
a form echelon-rowa in rows nonzero ofnumber
of columnst independenlinearly ofnumber maximum
of rowst independenlinearly ofnumber maximum
matrix a ofRank
0Ax xA
A
A
A
A
Problem 3
• Try the matrix [[1,0.3],[2,0.6]] in Problem 2.
• Find the (unique) matrix for Problem 2 for which the plot collapses to a single point.
• What is the connection between the rank of the matrices and the “shape” of the plot?
Example 4:Plot a Random Sample of Vectors (as Points)
L = [vector([random(),random()]) for i in range(20)]vector_plotter(L, points=True)
Problem 4
• Let L be the list of vectors from Example 4. Use the map function to multiply all vectors in L with the matrix [[1,0.3],[2,0.6]] and plot the resulting list using the vector_plotter function (with points=true).
• Observe carefully exactly where each original point lands. Is it random?
Example 5:Plot Vectors on a Certain Line
L = [random()*vector([3,-10]) for i in range(100)]vector_plotter(L, points=True)
Problem 5
a. Let L be the list of vectors from Example 4. Use the map function to multiply all vectors in L with the matrix [[1,0.3],[2,0.6]] and plot the resulting list using the vector_plotter function (with points=true).
b. What happens? Note: Numbers of absolute value <1e-15 can be considered as 0 (occur due to round off errors)
c. Compute the kernel of the matrix [[1,0.3],[2,0.6]]. Note: for a matrix A the sage-command A.right_kernel() returns a representation of the kernel of A.
d. What is the connection between the kernel of [[1,0.3],[2,0.6]] and the plot from part a?
Problem 6
The following generates random 4x5 matrices and computes their rank and kernel:
m = random_matrix(QQ, 4, 5, algorithm='echelonizable', rank=randint(0,4), upper_bound=60)print mprint m.rank()m.right_kernel()
Repeat this several times and especially take note of the connection between the rank and the dimension of the kernel. What is the mathematical theorem behind this?