Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can get the plot using a numerical approximation using desolve_rk4.

y=function('y',x)
f(x,y)=1-x*y
soln=desolve_rk4(f(x,y),y,ics=[0,0],ivar=x,end_points=20)
line(soln)

You can get the plot using a numerical approximation using desolve_rk4.

y=function('y',x)
f(x,y)=1-x*y
soln=desolve_rk4(f(x,y),y,ics=[0,0],ivar=x,end_points=20)
line(soln)

Edit:

You can also plot a slope field with the solution as follows.

y=function('y',x)
f(x,y)=1-x*y
soln=desolve_rk4(f(x,y),y,ics=[0,0],ivar=x,end_points=20)
p=line(soln)
p+=plot_slope_field(f(x,y),(x,0,20),(y,0,0.8))
show(p)

Or, if you prefer a slope field with arrows.

y=function('y',x)
f(x,y)=1-x*y
soln=desolve_rk4(f(x,y),y,ics=[0,0],ivar=x,end_points=20)
p=line(soln)
p+=plot_vector_field([1/sqrt(1+f(x,y)^2),f(x,y)/sqrt(1+f(x,y)^2)],(x,0,20),(y,0,0.8))
show(p)