Objectives
-
To understand that if a
matrix has two complex eigenvalues, then the general solution will involve sines and cosines. Furthermore, the origin will be a spiral sink, a spiral source or a center.
xxxxxxxxxx
x, y, t = var('x y t') #declare the variables
F = [3*x + 2*y, -3*x - y] #declare the system
# normalize the vector fields so that all of the arrows are the same length
n = sqrt(F[0]^2 + F[1]^2)
# plot the vector field
p = plot_vector_field((F[0]/n, F[1]/n), (x, -30, 30), (y, -30, 30), aspect_ratio = 1)
# solve the system for the initial condition t = 0, x = 1, y = 1
P1 = desolve_system_rk4(F, [x, y], ics=[0, 1, 1], ivar = t, end_points = 5, step = 0.01)
# grab the x and y values
S1 = [ [j, k] for i, j, k in P1]
# plot the solution
# Setting xmin, xmax, ymin, ymax will clip the window
# Try plotting without doing this to see what happens
p += line(S1, thickness = 2, axes_labels=['$x(t)$','$y(t)$'], xmin = -30, xmax = 30, ymin = -30, ymax = 30)
p
xxxxxxxxxx