Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
3

How to solve a differential equation of degree 5

asked 5 years ago

anonymous user

Anonymous

updated 5 years ago

slelievre gravatar image

I tried to solve this equation of degree 5:

d5ydx5+5d4ydx42d3ydx310d2ydx2+dydx+5y=0

with the following code:

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).show()

This gave the following error:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-9-c048996b444c> in <module>()
      2 y = function('y')(x)
      3 ED = diff(y,x,Integer(5))+Integer(5)*diff(y,x,Integer(4))-Integer(2)*diff(y,x,Integer(3))-Integer(10)*diff(y,x,Integer(2))+diff(y,x)+Integer(5)*y == Integer(0)
----> 4 desolve(ED,y,contrib_ode=true).show()

/opt/sagemath-8.6/local/lib/python2.7/site-packages/sage/calculus/desolvers.pyc in desolve(de, dvar, ics, ivar, show_method, contrib_ode, algorithm)
    593             soln = P(cmd)
    594             if str(soln).strip() == 'false':
--> 595                 raise NotImplementedError("Maxima was unable to solve this ODE.")
    596         else:
    597             raise NotImplementedError("Maxima was unable to solve this ODE. Consider to set option contrib_ode to True.")

NotImplementedError: Maxima was unable to solve this ODE.

How can I solve that?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
5

answered 5 years ago

dsejas gravatar image

updated 5 years ago

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: C3xe(x)+C1xex+C2e(x)+C4e(5x)+C0ex.

In order to make fricas available to your Sage installation, you will have to run the following command in your terminal: sage -i fricas. Fortunately, thanks to the help of Samuel Lelièvre and Andrey Novoseltsev, fricas is now available in 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: y1=dydx y2=dy1dx y3=dy2dx y4=dy3dx dy4dx+5y42y310y2+y1+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!

Preview: (hide)
link

Comments

1

Here's a public shared notebook with the code from above. You can run it live with one click and no account creation required: https://share.cocalc.com/share/df81e0...

William Stein gravatar imageWilliam Stein ( 5 years ago )

Nice! Thank you very much for adding to CoCalc!

dsejas gravatar imagedsejas ( 5 years ago )

Note: FriCAS is now available on SageCell as well, thanks to Andrey Novoseltsev. See this 2020-04 sage-cell discussion.

slelievre gravatar imageslelievre ( 5 years ago )

Thank you, @slelievre! I am updating my answer to reflect that.

dsejas gravatar imagedsejas ( 5 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 5 years ago

Seen: 627 times

Last updated: Apr 06 '20