# How to solve higher order (3rd or 4th) differential equation?

I am new to Sagemath. I was trying to solve ODE of order 4 in sagemath but it gives following error "NotImplementedError: Maxima was unable to solve this ODE."

x=var('x')
w = function('w')(x)
desolve(diff(w,x,4)==1,w,contrib_ode=True)


edit retag close merge delete

Sort by » oldest newest most voted

Hello, @sonimohit! Please, have a look to this answer that I previously posted on a similar question.

In simple terms, you can use Sage's fricas interface:

x = var('x')
w = function('w')(x)
desolve(diff(w,x,4)==1, w, algorithm='fricas')


Alternatively, you can construct a system of ODEs equivalent to your original equation:

x = var('x')
w = function('w')(x)
w1 = function('w1')(x)
w2 = function('w2')(x)
w3 = function('w3')(x)
w4 = function('w4')(x)
eq1 = w1 == diff(w, x) # first derivative of w
eq2 = w2 == diff(w1, x) # second derivative of w
eq3 = w3 == diff(w2, x) # third derivative of w
eq4 = w4 == diff(w3, x) # fourth derivative of w
eq5 = diff(w4,x) == 1 # this is your original equation
sol = desolve_system([eq1, eq2, eq3, eq4, eq5], [w,w1,w2,w3,w4], algorithm='fricas')
print(sol[0])


I hope this helps!

more