<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV>Thank you Julio for your confirmation,</DIV>
<DIV> </DIV>
<DIV>I checked that when tending the "pas_temps" to zero (t0, tf unchanged), the results tend to be the same.</DIV>
<DIV> </DIV>
<DIV>What about the first example?</DIV>
<DIV> </DIV>
<DIV>If a Scilab developer is near here, could (s)he give an explanation please? </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 size=2 face=Tahoma>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">De :</SPAN></B> Julio Gonzalez-Saenz <julio.gonzalez@ymail.com><BR><B><SPAN style="FONT-WEIGHT: bold">À :</SPAN></B> users@lists.scilab.org<BR><B><SPAN style="FONT-WEIGHT: bold">Envoyé le :</SPAN></B> Lun 3 mai 2010, 22 h 25 min 23 s<BR><B><SPAN style="FONT-WEIGHT: bold">Objet :</SPAN></B> Re: [scilab-Users] Re : [scilab-Users] A question about ode "rkf"<BR></FONT><BR>
<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 size=2 face=Tahoma>
<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 href="http://www.math.univ-metz.fr/~sallet/ODE_Scilab.pdf" rel=nofollow target=_blank>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 size=2 face=Tahoma>
<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 href="http://math.fullerton.edu/mathews/n2003/RungeKuttaFehlbergMod.html" rel=nofollow target=_blank>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></DIV></DIV></div><br>




      </body></html>