Processing math: 0%
Ask Your Question
1

How can I solve the following (linear) differential equation?

asked 6 years ago

Thrash gravatar image

updated 6 years ago

I want Sage to solve this equation: y.

Both

y=function('y')(x) 
desolve(diff(y,3)-3*diff(y,2)+diff(y,1)-5*y,y)

and

giac("desolve([y'''-3y''+y'-5y],y)").sage()

result in errors.

Preview: (hide)

Comments

giac gives an answer, but this answer fails to be converted to sage

FrédéricC gravatar imageFrédéricC ( 6 years ago )

2 Answers

Sort by » oldest newest most voted
2

answered 6 years ago

Emmanuel Charpentier gravatar image

updated 6 years ago

[ Not really an answer, but refinements needing more than the 500 characters of a comment ]

calc314's answer is an explicit solution :

import sympy
y=function("y")(x)
E1=diff(y(x),x,3)(x)-3*diff(y(x),x,2)(x)+diff(y(x),x)(x)-5*y(x)==0
Sol=sympy.dsolve(*map(sympy.sympify, [E1,y(x)]))._sage_()
Sol
y(x) == C3*e^(x*complex_root_of(x^3 - 3*x^2 + x - 5, 2)) + C2*e^(x*complex_root_of(x^3 - 3*x^2 + x - 5, 1)) + C1*e^(x*complex_root_of(x^3 - 3*x^2 + x - 5, 0))

The function complex_root_of(P,i) is a formal function representing the ith root of the polynomial P (in a stable fashion), which can be evaluated numerically). See its help docstring, as well as sympy's CRoot's.

If symbolic solutions are needed, you can also extract the characteristic polynomial and solve it symbolically :

Sol.rhs().operands()[0].operands()[1].operands()[0].operands()[1].operands()[0].solve(x)
[x == -1/2*(1/9*sqrt(235)*sqrt(3) + 3)^(1/3)*(I*sqrt(3) + 1) + 1/3*(I*sqrt(3) - 1)/(1/9*sqrt(235)*sqrt(3) + 3)^(1/3) + 1,
 x == -1/2*(1/9*sqrt(235)*sqrt(3) + 3)^(1/3)*(-I*sqrt(3) + 1) + 1/3*(-I*sqrt(3) - 1)/(1/9*sqrt(235)*sqrt(3) + 3)^(1/3) + 1,
 x == (1/9*sqrt(235)*sqrt(3) + 3)^(1/3) + 2/3/(1/9*sqrt(235)*sqrt(3) + 3)^(1/3) + 1]

But I think that the "formal root" form s a better expression in a lot of situations.

Preview: (hide)
link
1

answered 6 years ago

calc314 gravatar image

sympy does give a solution, but it leaves you to solve the characteristic equation.

from sympy import *
y=Function('y')
dsolve(Eq(Derivative(y(x),x,x,x)-3*Derivative(y(x),x,x)+Derivative(y(x),x) -5*y(x), 0), y(x))
Preview: (hide)
link

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: 6 years ago

Seen: 577 times

Last updated: Jan 17 '19