Ask Your Question

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

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 close merge delete

## Comments

2

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

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

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

( 2022-11-02 10:52:48 +0200 )edit

## 1 Answer

Sort by ยป oldest newest most voted

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,

more

## Your Answer

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

Add Answer

## Stats

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

Seen: 159 times

Last updated: Nov 02 '22