Ask Your Question
2

Why desolve() can not solve an ODE while SymPy can?

asked 2022-11-01 05:22:49 +0200

Mr_Spade gravatar image

For example, in sage, when I call:

x=var('x')
f=function('f')(x)
desolve(f.diff(x)^2+1,f)

It will return:

NotImplementedError: Maxima was unable to solve this ODE. Consider to set option contrib_ode to True.

However, with SymPy, when I call:

x=symbols('x')
f=symbols('f',cls=Function)
dsolve(f(x).diff(x)**2+1,f(x))

It will return the exact result:

[Eq(f(x), C1 - I*x), Eq(f(x), C1 + I*x)]

I know maybe it because sage use Maxima in desolve but not SymPy, however, I consider using both of them and merge the result is a better choice. Or if there already exists a method to use SymPy in sgae?

edit retag flag offensive close merge delete

Comments

2

desolve(f.diff(x)^2+1,f,contrib_ode=True) finds [-I*x - f(x) == _C]

tolga gravatar imagetolga ( 2022-11-01 17:31:09 +0200 )edit

"Merge the results" may be algorithmically hard. Choosing the "best" result even more so.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2022-11-02 10:52:48 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-11-02 10:50:45 +0200

Emmanuel Charpentier gravatar image

Try :

sage: f=function("f")
sage: import sympy
sage: Res = [u._sage_() for u in sympy.dsolve(*map(sympy.sympify, (f(x).diff(x)^2+1, f(x))))] ; Res
[f(x) == C1 - I*x, f(x) == C1 + I*x]

HTH,

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2022-11-01 05:22:49 +0200

Seen: 160 times

Last updated: Nov 02 '22