help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: octave and delay ode's


From: franco basaglia
Subject: Re: octave and delay ode's
Date: Sat, 7 Nov 2009 19:13:43 +0100

Thank you all for your work.

I have a last question.
I'd convert my ode system to a discrete-time system
with annual time step. In thsi way I can simplify my delay question.

 What is the octave solver to use? How can I plan the system in Octave?

The discrete system is something like that:

y1(t) = y1(t-1) -y1(t)
y2(t) = y2(t-1) -y2(t) + y1(t-5)
y3(t) = t3(t-1) -y3(t) + y2(t-10)*y1(t-10)



Thank you

best regards
f.b.






2009/11/5 Carlo de Falco <address@hidden>

On 5 Nov 2009, at 16:48, Thomas Treichl wrote:

Carlo de Falco schrieb:
Thomas,
On 2 Nov 2009, at 20:26, Thomas Treichl wrote:
Because there is an "ode" in the subject of the email, yes, but I also must say that I currently don't have the time to dig into this problem and can only provide a short answer: if the above equations form the DDE problem then Carlo's implementation does make more sense to me.
Thanks for your answer, I was not 100% sure I was doing things correctly as
it seems to me that the case of mutiple delays is not fully clear from the documentation (I looked at the implementation to find out the meaning of LAGS).
So if you believe my interpretation was correct, would you mind if I commit the patch below to improve the documentation of the DDE functions?

These changes would be an improvement.
Can you please make these changes also for ode45d, ode54d and ode78d?

Thanks, Thomas

I checked-in the patch below,
c.

Index: ode45d.m
===================================================================
--- ode45d.m    (revision 6438)
+++ ode45d.m    (revision 6439)
@@ -23,20 +23,54 @@
 %#
 %# If this function is called with no return argument then plot the solution over time in a figure window while solving the set of DDEs that are defined in a function and specified by the function handle @var{@@fun}. The second input argument @var{slot} is a double vector that defines the time slot, @var{init} is a double vector that defines the initial values of the states, @var{lags} is a double vector that describes the lags of time, @var{hist} is a double matrix and describes the history of the DDEs, @var{opt} can optionally be a structure array that keeps the options created with the command @command{odeset} and @var{par1}, @var{par2}, @dots{} can optionally be other input arguments of any type that have to be passed to the function defined by @var{@@fun}.
 %#
+%# In other words, this function will solve a problem of the form
+%# @example
+%# dy/dt = fun (t, y(t), y(t-lags(1), y(t-lags(2), @dots{})))
+%# y(slot(1)) = init
+%# y(slot(1)-lags(1)) = hist(1), y(slot(1)-lags(2)) = hist(2), @dots{}
+%# @end example
+%#
 %# If this function is called with one return argument then return the solution @var{sol} of type structure array after solving the set of DDEs. The solution @var{sol} has the fields @var{x} of type double column vector for the steps chosen by the solver, @var{y} of type double column vector for the solutions at each time step of @var{x}, @var{solver} of type string for the solver name and optionally the extended time stamp information @var{xe}, the extended solution information @var{ye} and the extended index information @var{ie} all of type double column vector that keep the informations of the event function if an event function handle is set in the option argument @var{opt}.
 %#
 %# If this function is called with more than one return argument then return the time stamps @var{t}, the solution values @var{y} and optionally the extended time stamp information @var{xe}, the extended solution information @var{ye} and the extended index information @var{ie} all of type double column vector.
 %#
-%# For example, solve an anonymous implementation of a chaotic behavior
+%# For example:
+%# @itemize @minus
+%# @item
+%# the following code solves an anonymous implementation of a chaotic behavior
+%#
 %# @example
 %# fcao = @@(vt, vy, vz) [2 * vz / (1 + vz^9.65) - vy];
 %#
-%# vopt = odeset ("NormControl", "on", "RelTol", 1e-4);
+%# vopt = odeset ("NormControl", "on", "RelTol", 1e-3);
 %# vsol = ode45d (fcao, [0, 100], 0.5, 2, 0.5, vopt);
 %#
 %# vlag = interp1 (vsol.x, vsol.y, vsol.x - 2);
 %# plot (vsol.y, vlag); legend ("fcao (t,y,z)");
 %# @end example
+%#
+%# @item
+%# to solve the following problem with two delayed state variables
+%#
+%# @example
+%# d y1(t)/ dt = -y1(t)

+%# d y2(t)/ dt = -y2(t) + y1(t-5)
+%# d y3(t)/dt  = -y3(t) + y2(t-10)*y1(t-10)
+%# @end example
+%#
+%# one might do the following
+%#
+%# @example
+%# function f = fun (t, y, yd)

+%# f(1) =-y(1);                   %% y1' = -y1(t)
+%# f(2) =-y(2) + yd(1,1);         %% y2' = -y2(t) + y1(t-lags(1))
+%# f(3) =-y(3) + yd(2,2)*yd(1,2); %% y3' = -y3(t) + y2(t-lags(2))*y1(t-lags(2))
+%# endfunction
+%# T = [0,20]
+%# res = ode45d (@fun, t, [1;1;1], [5, 10], ones (3,2));
+%# @end example
+%#
+%# @end itemize
 %# @end deftypefn
 %#
 %# @seealso{odepkg}
Index: ode54d.m
===================================================================
--- ode54d.m    (revision 6438)
+++ ode54d.m    (revision 6439)
@@ -23,11 +23,21 @@
 %#
 %# If this function is called with no return argument then plot the solution over time in a figure window while solving the set of DDEs that are defined in a function and specified by the function handle @var{@@fun}. The second input argument @var{slot} is a double vector that defines the time slot, @var{init} is a double vector that defines the initial values of the states, @var{lags} is a double vector that describes the lags of time, @var{hist} is a double matrix and describes the history of the DDEs, @var{opt} can optionally be a structure array that keeps the options created with the command @command{odeset} and @var{par1}, @var{par2}, @dots{} can optionally be other input arguments of any type that have to be passed to the function defined by @var{@@fun}.
 %#
+%# In other words, this function will solve a problem of the form
+%# @example
+%# dy/dt = fun (t, y(t), y(t-lags(1), y(t-lags(2), @dots{})))
+%# y(slot(1)) = init
+%# y(slot(1)-lags(1)) = hist(1), y(slot(1)-lags(2)) = hist(2), @dots{}
+%# @end example
+%#
 %# If this function is called with one return argument then return the solution @var{sol} of type structure array after solving the set of DDEs. The solution @var{sol} has the fields @var{x} of type double column vector for the steps chosen by the solver, @var{y} of type double column vector for the solutions at each time step of @var{x}, @var{solver} of type string for the solver name and optionally the extended time stamp information @var{xe}, the extended solution information @var{ye} and the extended index information @var{ie} all of type double column vector that keep the informations of the event function if an event function handle is set in the option argument @var{opt}.
 %#
 %# If this function is called with more than one return argument then return the time stamps @var{t}, the solution values @var{y} and optionally the extended time stamp information @var{xe}, the extended solution information @var{ye} and the extended index information @var{ie} all of type double column vector.
 %#
-%# For example, solve an anonymous implementation of a chaotic behavior
+%# For example:
+%# @itemize @minus
+%# @item
+%# the following code solves an anonymous implementation of a chaotic behavior
 %# @example
 %# fcao = @@(vt, vy, vz) [2 * vz / (1 + vz^9.65) - vy];
 %#
@@ -37,6 +47,29 @@
 %# vlag = interp1 (vsol.x, vsol.y, vsol.x - 2);
 %# plot (vsol.y, vlag); legend ("fcao (t,y,z)");
 %# @end example
+%#
+%# @item
+%# to solve the following problem with two delayed state variables
+%#
+%# @example
+%# d y1(t)/ dt = -y1(t)

+%# d y2(t)/ dt = -y2(t) + y1(t-5)
+%# d y3(t)/dt  = -y3(t) + y2(t-10)*y1(t-10)
+%# @end example
+%#
+%# one might do the following
+%#
+%# @example
+%# function f = fun (t, y, yd)

+%# f(1) =-y(1);                   %% y1' = -y1(t)
+%# f(2) =-y(2) + yd(1,1);         %% y2' = -y2(t) + y1(t-lags(1))
+%# f(3) =-y(3) + yd(2,2)*yd(1,2); %% y3' = -y3(t) + y2(t-lags(2))*y1(t-lags(2))
+%# endfunction
+%# T = [0,20]
+%# res = ode54d (@fun, t, [1;1;1], [5, 10], ones (3,2));
+%# @end example
+%#
+%# @end itemize
 %# @end deftypefn
 %#
 %# @seealso{odepkg}
Index: ode78d.m
===================================================================
--- ode78d.m    (revision 6438)
+++ ode78d.m    (revision 6439)
@@ -23,11 +23,21 @@
 %#
 %# If this function is called with no return argument then plot the solution over time in a figure window while solving the set of DDEs that are defined in a function and specified by the function handle @var{@@fun}. The second input argument @var{slot} is a double vector that defines the time slot, @var{init} is a double vector that defines the initial values of the states, @var{lags} is a double vector that describes the lags of time, @var{hist} is a double matrix and describes the history of the DDEs, @var{opt} can optionally be a structure array that keeps the options created with the command @command{odeset} and @var{par1}, @var{par2}, @dots{} can optionally be other input arguments of any type that have to be passed to the function defined by @var{@@fun}.
 %#
+%# In other words, this function will solve a problem of the form
+%# @example
+%# dy/dt = fun (t, y(t), y(t-lags(1), y(t-lags(2), @dots{})))
+%# y(slot(1)) = init
+%# y(slot(1)-lags(1)) = hist(1), y(slot(1)-lags(2)) = hist(2), @dots{}
+%# @end example
+%#
 %# If this function is called with one return argument then return the solution @var{sol} of type structure array after solving the set of DDEs. The solution @var{sol} has the fields @var{x} of type double column vector for the steps chosen by the solver, @var{y} of type double column vector for the solutions at each time step of @var{x}, @var{solver} of type string for the solver name and optionally the extended time stamp information @var{xe}, the extended solution information @var{ye} and the extended index information @var{ie} all of type double column vector that keep the informations of the event function if an event function handle is set in the option argument @var{opt}.
 %#
 %# If this function is called with more than one return argument then return the time stamps @var{t}, the solution values @var{y} and optionally the extended time stamp information @var{xe}, the extended solution information @var{ye} and the extended index information @var{ie} all of type double column vector.
 %#
-%# For example, solve an anonymous implementation of a chaotic behavior
+%# For example:
+%# @itemize @minus
+%# @item
+%# the following code solves an anonymous implementation of a chaotic behavior
 %# @example
 %# fcao = @@(vt, vy, vz) [2 * vz / (1 + vz^9.65) - vy];
 %#
@@ -37,6 +47,29 @@
 %# vlag = interp1 (vsol.x, vsol.y, vsol.x - 2);
 %# plot (vsol.y, vlag); legend ("fcao (t,y,z)");
 %# @end example
+%#
+%# @item
+%# to solve the following problem with two delayed state variables
+%#
+%# @example
+%# d y1(t)/ dt = -y1(t)

+%# d y2(t)/ dt = -y2(t) + y1(t-5)
+%# d y3(t)/dt  = -y3(t) + y2(t-10)*y1(t-10)
+%# @end example
+%#
+%# one might do the following
+%#
+%# @example
+%# function f = fun (t, y, yd)

+%# f(1) =-y(1);                   %% y1' = -y1(t)
+%# f(2) =-y(2) + yd(1,1);         %% y2' = -y2(t) + y1(t-lags(1))
+%# f(3) =-y(3) + yd(2,2)*yd(1,2); %% y3' = -y3(t) + y2(t-lags(2))*y1(t-lags(2))
+%# endfunction
+%# T = [0,20]
+%# res = ode78d (@fun, t, [1;1;1], [5, 10], ones (3,2));
+%# @end example
+%#
+%# @end itemize
 %# @end deftypefn
 %#
 %# @seealso{odepkg}
Index: ode23d.m
===================================================================
--- ode23d.m    (revision 6438)
+++ ode23d.m    (revision 6439)
@@ -23,11 +23,22 @@
 %#
 %# If this function is called with no return argument then plot the solution over time in a figure window while solving the set of DDEs that are defined in a function and specified by the function handle @var{@@fun}. The second input argument @var{slot} is a double vector that defines the time slot, @var{init} is a double vector that defines the initial values of the states, @var{lags} is a double vector that describes the lags of time, @var{hist} is a double matrix and describes the history of the DDEs, @var{opt} can optionally be a structure array that keeps the options created with the command @command{odeset} and @var{par1}, @var{par2}, @dots{} can optionally be other input arguments of any type that have to be passed to the function defined by @var{@@fun}.
 %#
+%# In other words, this function will solve a problem of the form
+%# @example
+%# dy/dt = fun (t, y(t), y(t-lags(1), y(t-lags(2), @dots{})))
+%# y(slot(1)) = init
+%# y(slot(1)-lags(1)) = hist(1), y(slot(1)-lags(2)) = hist(2), @dots{}
+%# @end example
+%#
 %# If this function is called with one return argument then return the solution @var{sol} of type structure array after solving the set of DDEs. The solution @var{sol} has the fields @var{x} of type double column vector for the steps chosen by the solver, @var{y} of type double column vector for the solutions at each time step of @var{x}, @var{solver} of type string for the solver name and optionally the extended time stamp information @var{xe}, the extended solution information @var{ye} and the extended index information @var{ie} all of type double column vector that keep the informations of the event function if an event function handle is set in the option argument @var{opt}.
 %#
 %# If this function is called with more than one return argument then return the time stamps @var{t}, the solution values @var{y} and optionally the extended time stamp information @var{xe}, the extended solution information @var{ye} and the extended index information @var{ie} all of type double column vector.
 %#
-%# For example, solve an anonymous implementation of a chaotic behavior
+%# For example:
+%# @itemize @minus
+%# @item
+%# the following code solves an anonymous implementation of a chaotic behavior
+%#
 %# @example
 %# fcao = @@(vt, vy, vz) [2 * vz / (1 + vz^9.65) - vy];
 %#
@@ -37,6 +48,29 @@
 %# vlag = interp1 (vsol.x, vsol.y, vsol.x - 2);
 %# plot (vsol.y, vlag); legend ("fcao (t,y,z)");
 %# @end example
+%#
+%# @item
+%# to solve the following problem with two delayed state variables
+%#
+%# @example
+%# d y1(t)/ dt = -y1(t)

+%# d y2(t)/ dt = -y2(t) + y1(t-5)
+%# d y3(t)/dt  = -y3(t) + y2(t-10)*y1(t-10)
+%# @end example
+%#
+%# one might do the following
+%#
+%# @example
+%# function f = fun (t, y, yd)

+%# f(1) =-y(1);                   %% y1' = -y1(t)
+%# f(2) =-y(2) + yd(1,1);         %% y2' = -y2(t) + y1(t-lags(1))
+%# f(3) =-y(3) + yd(2,2)*yd(1,2); %% y3' = -y3(t) + y2(t-lags(2))*y1(t-lags(2))
+%# endfunction
+%# T = [0,20]
+%# res = ode23d (@fun, t, [1;1;1], [5, 10], ones (3,2));
+%# @end example
+%#
+%# @end itemize
 %# @end deftypefn
 %#
 %# @seealso{odepkg}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]