direction fields

2486 days ago by chrisphan

var('x, y') vf = plot_vector_field((3*x - 2*y, 4*x - y), (x, -15, 30), (y, -25, 20), figsize=[8,8]) t = var('t') x = function('x', t) y = function('y', t) de1 = diff(x, t) == 3*x -2*y de2 = diff(y, t) == 4*x - y sol3 = desolve_system([de1, de2], [x,y], ics=[0, 0.5, -0.5]) xs = sol3[0].rhs() ys = sol3[1].rhs() deltat = 3.5/35 plots = [] currframe = vf for b in range(0, 35): currframe = currframe + parametric_plot([xs, ys], (deltat*b, deltat*(b+1))) if b % 5 == 0: currframe = currframe + text( "t = " + str(n(deltat*b, 3)), (xs(deltat*b) + 3, ys(deltat*b) - 1), rgbcolor=(0, 0.5, 0)) currframe = currframe + point([xs(deltat*b), ys(deltat*b)], size=20, rgbcolor=(1, 0, 0)) plots.append(currframe) anim = animate(plots, xmin=-15, xmax= 30, ymin=-25, ymax=20, figsize=[8,8]) html("This animation shows the solution of $x_1'= 3x_1 - 2x_2,\; x_2'=4x_1 - x_2,\; x_1(0) = 1/2,\; x_2(0)=-1/2$.") show(anim) 
       
This animation shows the solution of x_1'= 3x_1 - 2x_2,\; x_2'=4x_1 - x_2,\; x_1(0) = 1/2,\; x_2(0)=-1/2.
                                
                            
This animation shows the solution of x_1'= 3x_1 - 2x_2,\; x_2'=4x_1 - x_2,\; x_1(0) = 1/2,\; x_2(0)=-1/2.