Comparison between SageMath ODE solvers and Scipy ODE solvers

asked 2024-02-19 16:46:11 +0200

AKGSage gravatar image

I'm pretty new to SageMath and I'm currently trying to work on solving geodesic equations in well-defined spacetime manifolds. I found the documentation of SageMath pretty extensive and broad and it gave me a lot of confidence in the software. But I'm still hesitating to use Sage ODE solvers because I know the capabilities of RK45 from scipy.integrate as I have use that many times. I just want to know on a broad scale, are SageMath solvers faster than Scipy solvers and how reliable and stable are the solutions in general ?

Thanks in advance for the replies!

edit retag flag offensive close merge delete



Scipy solvers are numerical solvers, using numerical integration to get a solution of (systems of) ordinary differential equations.Sagemath "default" numerical solvers come from Maxima, and give reasonable answers in reasonable time. Sagemath also offers access to Scipy solvers, as you noted. As far as I know, no formal benchark of these implementations has been published.

But Sagemath offers an alternative : symbolic solutions. desolve (and desolve_system), as well as Sympy's dsolve (try to) solve ODE systems symbolically (Scipy also offers a rudimentary attempt to solve some partial differential equations). Many ODE and PDE (systems) do not have explicit symbolic solutions, but those who do should be solved this way, avoiding all the problems of numerical solutions.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2024-02-19 19:45:57 +0200 )edit

Note that the geodesic solveralready implemented in SageMath allows one to choose between many ODE solvers, from SciPy or from the GSL: The default geodesic solver is odeint from SciPy.

eric_g gravatar imageeric_g ( 2024-02-19 21:46:45 +0200 )edit

Okay so I will implement Scipy solvers as I need numerical solutions for my work. Thanks for pointing out the symbolic solvers in SageMath, I didn't know about them and thanks for the reference to geodesic solver, I'll surely check it out. Cheers!

AKGSage gravatar imageAKGSage ( 2024-02-20 07:20:17 +0200 )edit