Solve differential equation algebraically

Hi everyone,

I’m looking for a package that can solve differential equation similar to below Sage code:

sage: y = function('y')(x)
sage: de = diff(y, x) - y* 2 / x
sage: h = desolve(de, y)
sage: show(expand(h))
_C*x^2

Thank you for suggestion.

I don’t think so:

This is a suite for numerically solving differential equations

OP seems to be asking for “algebraic” (symbolic?) solutions here.

For symbolic computing there is

https://symbolics.juliasymbolics.org/stable/

in pure Julia and a wrapper around SymPy here:

But I’m not sure whether either of them can solve your example.

2 Likes

You can do it for sure using SymPy:

julia> using SymPy
julia> @syms x
(x,)
julia> y = sympy.Function("y")
PyObject y
julia> result = dsolve(sympy.Derivative(y(x), x) -  2*y(x)/x)
           2
y(x) = C₁⋅x 

However SymPy under the hood uses the Python library with the same name. If performance is a concern, there exist a newer Julia-only package (also better integrated with the rest of the Julia eco-system), Symbolics.jl.
But I don’t know if Symbolics already has algebraic solver for differential equations.

1 Like

I had a look on the documentation of both Symbolics.jl and ModellingToolkits.jl, but I could not find anywhere a point if algebraic resolution of simple differential equations is possible with them.
Whether is the case, I think a note on this should go in the documentation…

1 Like

We don’t have a general symbolic differential equation solving function in ModelingToolkit/Symbolics yet. For now, SymPy.jl is the way to go.

1 Like