CoCalc Shared FilesTA Sandbox / Daniel's Sandbox / HW5-P2.sagews
Authors: Kristin McCully, Daniel Sun
Views : 12
Description: HW5-p2, spring 2016
var("R")
var("J"


R J
#preliminary plot of the vector field
# Exercise 2: Plot of eigenvector lines (eigenlines)
eigenvector1 = plot(-1.5*R,(R,-10,10),legend_label="Dominant Eigenvector")
eigenvector2 = plot(1/3*R,(R,-10,10),color="red",ymin=-10,ymax=10,legend_label="Non-dominant Eigenvector")
show(eigenvector1 + eigenvector2)

# We can always reconstruct the matrix if we know the eigenvalue-eigenvector pairs

E = matrix([[-2,3],[3,1]])
E.inverse()*vector([1,0])

(-1/11, 3/11)
c1 = -1*-1/11*vector([-2,3])-4*3/11*vector([3,1])
c1

(-38/11, -9/11)
E.inverse()*vector([0,1])

(3/11, 2/11)
c2 = -1*3/11*vector([-2,3])-4*2/11*vector([3,1])


# Reconstructing the matrix
A = column_matrix(QQ,[c1,c2])
A

[-38/11 -18/11] [ -9/11 -17/11]
# The eigenvalues and eigenvectors of the this matrix match the original ones that we were given.
A.eigenvectors_right()

[(-1, [ (1, -3/2) ], 1), (-4, [ (1, 1/3) ], 1)]


# Plotting the linear differential system, the trajectories "rush" in towards the dominant eigenline and then decay slowly towards the origin.
Rprime(R,J) = A[0,0]*R + A[0,1]*J
Jprime(R,J) = A[1,0]*R + A[1,1]*J
system = [Rprime,Jprime]
show(plot_vector_field([Rprime,Jprime],(R,-10,10),(J,-10,10)) + plot(-1.5*R,(R,-10,10),legend_label="dominant eigenvector")+plot(1/3*R,(R,-10,10),color="red",ymin=-10,ymax=10,legend_label="non-dominant eigenvector"), svg=false)
show(Rprime)
show(Jprime)

$\displaystyle \left( R, J \right) \ {\mapsto} \ -\frac{18}{11} \, J - \frac{38}{11} \, R$
$\displaystyle \left( R, J \right) \ {\mapsto} \ -\frac{17}{11} \, J - \frac{9}{11} \, R$