Objectives
- To understand and be able to solve systems
where is a matrix with a single eigenvalue
xxxxxxxxxx
x, y, t = var('x y t') #declare the variables
F = [3*x + y, -4*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, -20, 20), (y, -20, 20), aspect_ratio = 1)
# solve the system for the initial condition t = 0, x = -2, y = 5
P1 = desolve_system_rk4(F, [x, y], ics=[0, -2, 5], 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 = -20, xmax = 20, ymin = -20, ymax = 20)
# plot the straight-line solutions
p += line([(-10, 20), (10, -20)], thickness = 2, color = "red")
p
xxxxxxxxxx