<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div>Hi Bouchra,<br><br>I am not a SCILAB developer, but normally an ODE uses a variable step size based on the relative error, in the case (x,y) it uses the you have a x-component of the error and a y-component of the error.. so is in the first case, just x-component.. Therefore if you start where the error is big, you have small step size, while if you have small error, you can increase the step size..<br><br>I would like to hear an answer from the development team about this, but 90% sure your approach is correct...<br><br>Regards,<br><br>Julio<br></div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b>
 Bouchra Bensiali <bouchra.bensiali@yahoo.fr><br><b><span style="font-weight: bold;">To:</span></b> users@lists.scilab.org<br><b><span style="font-weight: bold;">Sent:</span></b> Mon, 3 May, 2010 19:50:30<br><b><span style="font-weight: bold;">Subject:</span></b> [scilab-Users] Re : [scilab-Users] A question about ode "rkf"<br></font><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">
<div>Hi,</div>
<div> </div>
<div>I come with concrete examples, and wish I can find some help.</div>
<div> </div>
<div>After some research <font color="#008000"><a rel="nofollow" target="_blank" href="http://www.math.univ-metz.fr/%7Esallet/ODE_Scilab.pdf">www.math.univ-metz.fr/~sallet/<b>ODE_Scilab</b>.<b>pdf</b></a><b></b></font>, it seems that the methods used by ode choose their steps to control errors. They are not fixed step solvers.</div>
<div> </div>
<div>But have some questions:</div>
<div> </div>
<div>1/ Consider this:</div>
<div>=========================================================================</div>
<div>function Xdot=F(t,X)<br>  printf("t=%f \n ",t)<br>  <br>  Xdot = ((1-t)*X-X^2)/(10^(-4));<br>  <br>endfunction<br><br>//<br>pas_temps=0.001;<br>t0=170*pas_temps;<br>tf=180*pas_temps;<br><br>X0=1;<br><br>Trajectoire1=ode("rkf",X0,t0,t0:pas_temps:tf,F);<br><br>//<br>printf("\n \n");<br><br>t0=178*pas_temps;<br>tf=180*pas_temps;<br><br>X0=Trajectoire1(:,9);<br><br>Trajectoire2=ode("rkf",X0,t0,t0:pas_temps:tf,F);<br><br>//comparaison<br>Dif = Trajectoire1(:,9:$)-Trajectoire2</div>
<div>=============================================================================</div>
<div>If you try this example, you'll find that the intermediate times used between t=0.178 and t=0.179 (to predict the solution at t=0.179) are not the same in the first and second integration. Why the time t=0.178 is not handeled the same way? A depandance to what happened before maybe?</div>
<div> </div>
<div> </div>
<div>2/ My initial problem was that integrating xdot = f(t,x), x(t0)=x0, or integrationg together xdot=f(t,x), ydot=g(t,y), x(t0)=x0, y(t0)=y0, don't give the same result for x. An example that illustrates this is the following:</div>
<div>==============================================================================</div>
<div>function Xdot=F1(t,X)<br>  printf("t=%f \n ",t)<br>  <br>  Xdot = X/10^(-3);<br>  <br>endfunction<br><br>//<br>pas_temps=0.001;<br>t0=170*pas_temps;<br>tf=172*pas_temps;<br><br>X0=1;<br><br>Trajectoire1=ode("rkf",X0,t0,t0:pas_temps:tf,F1);<br><br>//<br>printf("\n \n");<br><br>function Xdot=F2(t,X)<br>  printf("t=%f \n ",t)<br>  <br>  Xdot = [X(1)/10^(-3);((1-t)*X(2)-X(2)^2)/(10^(-4))];<br>  <br>endfunction<br><br>//<br>pas_temps=0.001;<br>t0=170*pas_temps;<br>tf=172*pas_temps;<br><br>X0=[1;1];<br><br>Trajectoire2=ode("rkf",X0,t0,t0:pas_temps:tf,F2);<br><br>//comparaison<br>Dif = Trajectoire1 - Trajectoire2(1,:)</div>
<div>===================================================================================</div>
<div>From what I understood, the "rkf" method, as the ode45 (Matlab) is a variable step solver: if the estimated error is bigger than the tolerance, the stepsize is reduced. In the second integration, the error is related to x and y, while in the first integration, it's only related to x, so that can explain the difference in the results. Confirmation?</div>
<div> </div>
<div>Thanks.</div>
<div> </div>
<div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br>
<div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Tahoma" size="2">
<hr size="1">
<b><span style="font-weight: bold;">De :</span></b> Bouchra Bensiali <bouchra.bensiali@yahoo.fr><br><b><span style="font-weight: bold;">À :</span></b> users@lists.scilab.org<br><b><span style="font-weight: bold;">Envoyé le :</span></b> Ven 30 avril 2010, 16 h 21 min 41 s<br><b><span style="font-weight: bold;">Objet :</span></b> [scilab-Users] A question about ode "rkf"<br></font><br>
<div style="font-family: times new roman,new york,times,serif; color: rgb(0, 0, 0); font-size: 12pt;">
<div>Hi,</div>
<div> </div>
<div>I wonder if the "rkf" method uses a fixed number of intermediate times as said here <a rel="nofollow" target="_blank" href="http://math.fullerton.edu/mathews/n2003/RungeKuttaFehlbergMod.html">http://math.fullerton.edu/mathews/n2003/RungeKuttaFehlbergMod.html</a>.</div>
<div> </div>
<div>For example, if I define a function F:</div>
<div>--</div>
<div>function Xdot=F(t,X)<br><br>  //printf("t=%f \n",t)<br>  <br>  Xdot = ... ;<br>  <br>endfunction;</div>
<div>--</div>
<div>and make a first integration:</div>
<div>--</div>
<div>pas_temps = 0.001;<br>t0 = 170*pas_temps;<br>tf = 180*pas_temps;<br><br>X0 = ... ;<br><br>Trajectoire1 = ode("rkf",X0,t0,t0:pas_temps:tf,F);</div>
<div>--</div>
<div>and a second integration beginning with the result obtained at time t=0.178 (for example):</div>
<div>--</div>
<div>t0 = 178*pas_temps;<br>tf = 180*pas_temps;<br><br>X0 = Trajectoire1(:,9);<br><br>Trajectoire2 = ode("rkf",X0,t0,t0:pas_temps:tf,F);</div>
<div>--</div>
<div>then is Trajectoire2 supposed to be the same as Trajectoire1(:,9:11)?</div>
<div> </div>
<div>Because I have an example that gives different results and found (by using printf("t=%f \n",t)) that the number of intermediate times changed from one integration to another.</div>
<div> </div>
<div>Thank you in advance for your help. I'm really stuck.</div></div></div></div></div></div><br>




      </div></div>
</div><br>



      </body></html>