Revision history [back]

How can I solve this equation using SageMath?

#general solution
y = function('y')(x)
de = diff(y,x)*(4*x+2*y-3) - 2*x-y-1
solution = desolve(de, y)
solution.show()

#Cauchi problem solution
y=function('y')(x)
de = diff(y,x)*(4*x+2*y-3) - 2*x-y-1
solution=desolve(de,y,ics=[-2,1])
solution.show()
solution1=desolve(de,y,ics=[2,-1])
solution1.show()
solution2=desolve(de,y,ics=[1,1])
solution2.show()
solution3=desolve(de,y,ics=[-1,-1])
solution3.show()

#direction fields
x = var('x')
y = var('y')
f(x,y)= diff(y,x)*(4*x+2*y-3) - 2*x-y-1
headlength=5,axes_labels=['$x$','$y(x)$'])

#plot of Cauchi problem solution
p+=desolve_rk4(f,y,ics=[-2,1],ivar=x,output='plot',
end_points=[-10,10],thickness=2,rgbcolor=hue(1))
p1=desolve_rk4(f,y,ics=[2,-1],ivar=x,output='plot',
end_points=[-10,10],thickness=2,rgbcolor=hue(0.2))
p2=desolve_rk4(f,y,ics=[1,1],ivar=x,output='plot',
end_points=[-10,10],thickness=2,rgbcolor=hue(0.5))
p3=desolve_rk4(f,y,ics=[-1,-1],ivar=x,output='plot',
end_points=[-10,10],thickness=2,rgbcolor=hue(0.3))
show(p+p1+p2+p3,xmin=-10,xmax=10,ymin=-10,ymax=10)
_____
NotImplementedError: Maxima was unable to solve this ODE. Consider to set option contrib_ode to True.


Here I want to find a solution for a differential equation, solve Cauchi problem and show direction fields. However, Sage can not solve it. It returns an error, showed in the code above. It is solved by hand. So, what can I possibly do?

Equation itself looks like this: (2x+y+1)dx - (4x+2y-3)dy = 0

Thank you

 2 retagged FrédéricC 5141 ●3 ●43 ●112

How can I solve this equation using SageMath?

#general solution
y = function('y')(x)
de = diff(y,x)*(4*x+2*y-3) - 2*x-y-1
solution = desolve(de, y)
solution.show()

#Cauchi problem solution
y=function('y')(x)
de = diff(y,x)*(4*x+2*y-3) - 2*x-y-1
solution=desolve(de,y,ics=[-2,1])
solution.show()
solution1=desolve(de,y,ics=[2,-1])
solution1.show()
solution2=desolve(de,y,ics=[1,1])
solution2.show()
solution3=desolve(de,y,ics=[-1,-1])
solution3.show()

#direction fields
x = var('x')
y = var('y')
f(x,y)= diff(y,x)*(4*x+2*y-3) - 2*x-y-1
headlength=5,axes_labels=['$x$','$y(x)$'])

#plot of Cauchi problem solution
p+=desolve_rk4(f,y,ics=[-2,1],ivar=x,output='plot',
end_points=[-10,10],thickness=2,rgbcolor=hue(1))
p1=desolve_rk4(f,y,ics=[2,-1],ivar=x,output='plot',
end_points=[-10,10],thickness=2,rgbcolor=hue(0.2))
p2=desolve_rk4(f,y,ics=[1,1],ivar=x,output='plot',
end_points=[-10,10],thickness=2,rgbcolor=hue(0.5))
p3=desolve_rk4(f,y,ics=[-1,-1],ivar=x,output='plot',
end_points=[-10,10],thickness=2,rgbcolor=hue(0.3))
show(p+p1+p2+p3,xmin=-10,xmax=10,ymin=-10,ymax=10)
_____
NotImplementedError: Maxima was unable to solve this ODE. Consider to set option contrib_ode to True.


Here I want to find a solution for a differential equation, solve Cauchi problem and show direction fields. However, Sage can not solve it. It returns an error, showed in the code above. It is solved by hand. So, what can I possibly do?

Equation itself looks like this: (2x+y+1)dx - (4x+2y-3)dy = 0

Thank you