ODE : not the same solution after adding independent equations

1 view (last 30 days)
Hello everybody,
I'm using Matlab to solve a non linear system of differential equations. To test my modeling I tested a portion of my system which can be written as following :
dX = - pX + eY
dY = pX - eY
But if I add other equations that are independent from the first ones in this way :
dX = - pX + eY
dY = pX - eY
dA = -pA + eB
dB = pA - eB
In that case, I'll not obtain the same result after resolution than in the first case (the difference is very small but still, it's there). I searched for dissimilarities in my program but I found none excluding the new couple of equations. Finally, it appears in the detailed results given by ODE solver that the two resolution path are getting away from each other progressively. It made me think that the problem was linked to ode solver. I resolved my equations with ode45, I also tried this little test with ode15s and obtained the same result. It seems weird to me that these couple of equations which are independent from each other influence their respective results.
So my question is : is it linked to ode solver and is not a mistake or is there a mistake in my program? Or is there an other reason?
I thank you a lot,
Claire

Answers (1)

Star Strider
Star Strider on 2 Apr 2014
You did not post your code calling ode45, so I am guessing here.
If you called them as:
[T Y] = ode45(@odefun, [Tstart Tend], ... )
check to see if the times T are the same in both. The ODE solvers are adaptive, and the presence of the additional equations could influence the solver’s behaviour.
  2 Comments
Roubinet
Roubinet on 3 Apr 2014
Hello,
Thanks for your answer and sorry for the lack of precision. I'm calling ode45 in this way :
First I define the parameters named p and e above then I define the time interval like
tmin = a;
tmax = b;
t_inter = linspace(tmin, tmax, 500)
Then I define the initial conditions that I put in a vector N0 to finally call ode45 in this way :
[t,N] = ode45('model',t_inter,N0, [], [p e])
So in doing this, the resolution will be done for the time defined by t_inter and thus the times T are the same in both.
So it doesn't seem to be this point the source of the problem.
Nonetheless, thanks a lot,
Claire
Star Strider
Star Strider on 3 Apr 2014
As I understand it, the ODE solvers output their results corresponding to the times in the t_inter vector but calculate them adaptively.
From the ode45 documentation:
  • Specifying tspan with more than two elements does not affect the internal time steps that the solver uses to traverse the interval from tspan(1) to tspan(end). All solvers in the ODE suite obtain output values by means of continuous extensions of the basic formulas. Although a solver does not necessarily step precisely to a time point specified in tspan, the solutions produced at the specified time points are of the same order of accuracy as the solutions computed at the internal time points.
  • Specifying tspan with more than two elements has little effect on the efficiency of computation, but for large systems, affects memory management.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!