def grid(v1,v2,endpoints=[-3,3,-3,3],color='gray'): G = Graphics() for i in range(endpoints[0],endpoints[1]): for j in range(endpoints[2],endpoints[3]): G += line([i*v1+j*v2,(i+1)*v1+j*v2],color=color,aspect_ratio=1) G += line([i*v1 + j*v2, i*v1 + (j+1)*v2], color=color, aspect_ratio=1) return G def grid_vecs(v1,v2,endpoints=[-3,3,-3,3],color='gray'): G = grid(v1,v2,endpoints,color) G += plot(v1,color='green') G += plot(v2,color='purple') return G
# Standard basis V = VectorSpace(QQ, 2) e1, e2 = V.basis() grid_vecs(e1,e2)
# Image of standard basis under A A = matrix([[2,-1],[1,1]]) grid_vecs(A*e1,A*e2)
# Basis vectors for alpha v1 = vector([1,1]) v2 = vector([-1,0]) grid_vecs(v1,v2)
# Matrix with respect to alpha P = matrix([v1,v2]).transpose(); B = P.inverse()*A*P; B
[ 2 -1]
[ 1 1]
# Action of A on alpha A*v1 A*v2
(1, 2)
(-2, -1)
# Check that this is consistent with B 2*v1+v2 -v1+v2
(1, 2)
(-2, -1)
# You might need to squint, but you can imagine the above grid being transformed so that # new_green = 2*old_green+1*old_purple, new_purple = -old_green+old_purple to get the following picture grid_vecs(A*v1,A*v2)