# How reliable is the approximate solution computed by ode45 with default 'Abstol' and 'Reltol' values (the analytic solution of the ode is unknown)?

19 Ansichten (letzte 30 Tage)
Rebeka am 15 Dez. 2022
I stumbled upon some unexpected results while numerically solving a system of odes using the 'solve_ivp' function in Python. My aim was to reproduce the result which I have from MATLAB (ode45) in Python using the same rk4(5) method, But to my surprise I found a particular case ( for a particular set of parameters) where the two functions are giving different solution. All the parameter values, initial conditions, and 'Abstol' and 'Reltol' (1e-6 and 1e-3 respectevily) are same. Both solutions are giving periodic orbits but of different kind, that means the solutions are converging, therefore the integration is successful and some solution is reached, but why are they different? Are there two co-existing solutions? and why two softwares converging to different solutions? As I have no idea of the analytic solution of my system what can be said about the accuracy of the numerical methods?
Also It will be very helpful if someone can shed some light on the use of 'Abstol' and 'Reltol'. As I learned from various sources the 'Reltol' decides the number of correct digits. Does it mean the solution I am getting is correct upto third decimal place? The local error of RK4 is O(h^5), but ode45 computes solution with variable stepsize. Is that the reason we need to specify the 'Reltol' to have a universal control over the error? Or am I completely wrong about the understanding of 'Reltol'!
Though I have two different questions, but I think they may be related to give a plausible explanation about these discrepancies in result.
I am attaching few plots computed in MATLAB and Python for comparison. If you notice the Python plot you will see the solution is staying close to two regions for quite some time, I guess one of those is the MATLAB solution.
Any input here is welcome. Thanks in advance.
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!