Direction Fields & Integral Curves

3157 days ago by dwatson

Define variables (x & y), differential equation (df), and solution (C)

x,y=var('x,y') df = -y/2+3/2*x C = exp(1/2*x)*(y-3*x+6) 
       

Create direction field (plot_slope_field)

v=plot_slope_field(df,(x,-2,2),(y,-2,2)) 
       

Create Integral Curves (contour_plot)

d = contour_plot(C, (x,-2, 2), (y,-2,2),fill = False, linewidths = 5, contours = 10, cmap = 'hsv') 
       

Create particular solution if ininital condition is given

e = plot(0.5*exp(-2*x)*(x^2-1),(x,-1,2)) g = point([1,0],size = 50) 
       

Plot direction field and integral curve

plot(v)