213 - A10.3 - Visual Eigensystems

184 days ago by Professor213

John Travis

Mississippi College

Demonstrating the eigenvalue/eigenvector relationship in 2d and 3d

# 2x2 matrix and corresponding 2d view A = matrix(QQ,[[1, 8], [5, 4]]) D, V = A.eigenmatrix_right() lam = [D[0][0],D[1][1]] @interact def _(angle = slider(0,360,1,30),n = [0,1],Show_Eigenvector=checkbox(default=False)): html('In this interactive cell, for each of the two eigenvalues determine the corresponding eigenvector') html('by finding the direction angle for which the resulting vector x satisfies $Ax = \lambda x$.') html('The <font color="green">green</font> vector below corresponds to $\lambda x$ and the <font color="red">red</font> vector corresponds to $Ax$') print ref_angle = (atan(V[1][n]/V[0][n])*180/pi).n(digits=3) print "Eigenvalue =", lam[n] if Show_Eigenvector: print "Eigenvector =", V[n] print ref_angle show(A) angle = angle*pi/180 vec = [cos(angle).n(digits=3),sin(angle).n(digits=3)] html('Using the entered angle above yields the vector given by') show(vec) veclam = [lam[n]*cos(angle),lam[n]*sin(angle)] G = arrow((0,0),veclam,color='green',zorder=3) Ax = A*(vector(RR,[vec[0],vec[1]]).column()) Ax = (Ax[0][0],Ax[1][0]) G+= arrow((0,0),Ax,color='red',zorder=2) G.show(aspect_ratio=True,figsize=(4,6)) V*D == A*V 
       

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

# 3x3 matrix and corresponding 3D view A = matrix(QQ,[[1, 6, 0], [3, 4, 0], [1, 1, 1]]) D, V = A.eigenmatrix_right() lam = [D[0][0],D[1][1],D[2][2]] @interact def _(theta = slider(0,360,1,30,label='$\\theta$ (rotation)'),phi = slider(0,180,1,30,label="$\\phi$ (elevation from N)"),n = [0,1,2]): html('In this interactive cell, for each of the two eigenvalues determine the corresponding eigenvector') html('by finding the direction angle for which the resulting vector x satisfies $Ax = \lambda x$') print "Eigenvalue =", lam[n] print "Eigenvector=", V[n] show(A) theta = theta*pi/180 phi = phi*pi/180 vec = [cos(theta)*sin(phi),sin(theta)*sin(phi),cos(phi)] # spherical coordinates veclam = [lam[n]*cos(theta)*sin(phi),lam[n]*sin(theta)*sin(phi),lam[n]*cos(phi)] G = arrow((0,0,0),veclam,color='green',zorder=3) Ax = A*(vector(RR,[vec[0],vec[1],vec[2]]).column()) Ax = (Ax[0][0],Ax[1][0],Ax[2][0]) G+= arrow((0,0,0),Ax,color='red',zorder=2) G.show(aspect_ratio=True,figsize=(4,6)) V*D == A*V 
       

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