Ask Your Question

stonefaceq's profile - activity

2023-10-21 16:12:37 +0200 marked best answer 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
p=plot_slope_field(f,(x,-10,10),(y,-10,10), headaxislength=5,
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

2023-10-21 16:12:37 +0200 received badge  Scholar (source)
2023-10-20 21:32:51 +0200 asked a question How can I solve this equation using SageMath?

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-