Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hello! Sage uses Maxima to solve ODEs. In this particular case, however, Maxima is unable to solve it, and this can be due to one of two reasons: 1. Sage seems to be failing to pass this ODE to Maxima for it to do it's job. Thus, the NotImplementedError. 2. Maxima is not clever enough to solve this ODE. (I really don't know which of these is the case, but I will certainly make some research on it.)

The easiest way to solve this problem is to force Sage to use fricas instead of Maxima. You can do that with the following:

x = var('x')
y = function('y')(x)
ED = diff(y,x,5)+5*diff(y,x,4)-2*diff(y,x,3)-10*diff(y,x,2)+diff(y,x)+5*y == 0
desolve(ED,y,contrib_ode=true,algorithm='fricas').show()

You will get the following: $$_{C_{3}} x e^{\left(-x\right)} + _{C_{1}} x e^{x} + _{C_{2}} e^{\left(-x\right)} + _{C_{4}} e^{\left(-5 \, x\right)} + _{C_{0}} e^{x}.$$

In order to make fricas available to your Sage installation, you will have to run the following command in your terminal: sage -i fricas. Unfortunately, fricas is not available in SageCell, but you can use CoCalc (which has fricas already installed) if you don't have a Sage local installation.

Another simple way to solve an equation like this is to convert it to a system: $$y_1 = \frac{dy}{dx}$$ $$y_2 = \frac{dy_1}{dx}$$ $$y_3 = \frac{dy_2}{dx}$$ $$y_4 = \frac{dy_3}{dx}$$ $$\frac{dy_4}{dx}+5y_4-2y_3-10y_2+y_1+5y = 0$$

Then, you can use the desolve_system command:

x = var('x')                                                                         
y = function('y')(x)
y1 = function('y1')(x)                                                        
y2 = function('y2')(x)                                  
y3 = function('y3')(x)
y4 = function('y4')(x)
eq1 = y1 == diff(y, x)
eq2 = y2 == diff(y1, x)
eq3 = y3 == diff(y2, x)
eq4 = y4 == diff(y3, x)
eq5 = diff(y4,x) + 5*y4 - 2*y3 - 10*y2 + y1 + 5*y == 0
sol = desolve_system([eq1, eq2, eq3, eq4, eq5], [y,y1,y2,y3,y4], algorithm='fricas')
sol[0]

In this case, Maxima IS able to solve the system, but the solution is not written in a useful way ---that is why I used fricas also here. For this particular ODEs, when using Maxima, you are going to need to replace the values of y1, y2, y3 and y4 into y, and replace y(0) with _C0, y1(0) with _C1, etc. I don't imagine you wanting to do that, but I am writing the commands anyway, just in case somebody else finds that useful for another system:

x = var('x')                                                                         
y = function('y')(x)
y1 = function('y1')(x)                                                        
y2 = function('y2')(x)                                  
y3 = function('y3')(x)
y4 = function('y4')(x)
eq1 = y1 == diff(y, x)
eq2 = y2 == diff(y1, x)
eq3 = y3 == diff(y2, x)
eq4 = y4 == diff(y3, x)
eq5 = diff(y4,x)+5*y4-2*y3-10*y2+y1+5*y == 0
sol = desolve_system([eq1, eq2, eq3, eq4, eq5], [y,y1,y2,y3,y4])
sol

(... and here comes the process of replacing expressions ...)

I hope this helps!

Hello! Sage uses Maxima to solve ODEs. In this particular case, however, Maxima is unable to solve it, and this can be due to one of two reasons: 1. Sage seems to be failing to pass this ODE to Maxima for it to do it's job. Thus, the NotImplementedError. 2. Maxima is not clever enough to solve this ODE. (I really don't know which of these is the case, but I will certainly make some research on it.)

The easiest way to solve this problem is to force Sage to use fricas instead of Maxima. You can do that with the following:

x = var('x')
y = function('y')(x)
ED = diff(y,x,5)+5*diff(y,x,4)-2*diff(y,x,3)-10*diff(y,x,2)+diff(y,x)+5*y == 0
desolve(ED,y,contrib_ode=true,algorithm='fricas').show()

You will get the following: $$_{C_{3}} x e^{\left(-x\right)} + _{C_{1}} x e^{x} + _{C_{2}} e^{\left(-x\right)} + _{C_{4}} e^{\left(-5 \, x\right)} + _{C_{0}} e^{x}.$$

In order to make fricas available to your Sage installation, you will have to run the following command in your terminal: sage -i fricas. Unfortunately, Fortunately, thanks to the help of Samuel Lelièvre and Andrey Novoseltsev, fricas is not now available in SageCell, but you SageCell. You can also use CoCalc (which has fricas already installed) if you don't have a Sage local installation.

Another simple way to solve an equation like this is to convert it to a system: $$y_1 = \frac{dy}{dx}$$ $$y_2 = \frac{dy_1}{dx}$$ $$y_3 = \frac{dy_2}{dx}$$ $$y_4 = \frac{dy_3}{dx}$$ $$\frac{dy_4}{dx}+5y_4-2y_3-10y_2+y_1+5y = 0$$

Then, you can use the desolve_system command:

x = var('x')                                                                         
y = function('y')(x)
y1 = function('y1')(x)                                                        
y2 = function('y2')(x)                                  
y3 = function('y3')(x)
y4 = function('y4')(x)
eq1 = y1 == diff(y, x)
eq2 = y2 == diff(y1, x)
eq3 = y3 == diff(y2, x)
eq4 = y4 == diff(y3, x)
eq5 = diff(y4,x) + 5*y4 - 2*y3 - 10*y2 + y1 + 5*y == 0
sol = desolve_system([eq1, eq2, eq3, eq4, eq5], [y,y1,y2,y3,y4], algorithm='fricas')
sol[0]

In this case, Maxima IS able to solve the system, but the solution is not written in a useful way ---that is why I used fricas also here. For this particular ODEs, when using Maxima, you are going to need to replace the values of y1, y2, y3 and y4 into y, and replace y(0) with _C0, y1(0) with _C1, etc. I don't imagine you wanting to do that, but I am writing the commands anyway, just in case somebody else finds that useful for another system:

x = var('x')                                                                         
y = function('y')(x)
y1 = function('y1')(x)                                                        
y2 = function('y2')(x)                                  
y3 = function('y3')(x)
y4 = function('y4')(x)
eq1 = y1 == diff(y, x)
eq2 = y2 == diff(y1, x)
eq3 = y3 == diff(y2, x)
eq4 = y4 == diff(y3, x)
eq5 = diff(y4,x)+5*y4-2*y3-10*y2+y1+5*y == 0
sol = desolve_system([eq1, eq2, eq3, eq4, eq5], [y,y1,y2,y3,y4])
sol

(... and here comes the process of replacing expressions ...)

I hope this helps!