Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
27
Добавлен:
09.02.2015
Размер:
406.02 Кб
Скачать

Initial value problem solver for delay differential equations (ddEs)

<dde23> - Solve delay differential equations (DDEs) with constant delays.

DDE23 Solve delay differential equations (DDEs) with constant delays.

SOL = DDE23(DDEFUN,LAGS,HISTORY,TSPAN) integrates a system of DDEs

y'(t) = f(t,y(t),y(t - tau_1),...,y(t - tau_k)). The constant, positive

delays tau_1,...,tau_k are input as the vector LAGS. DDEFUN is a function

handle. DDEFUN(T,Y,Z) must return a column vector corresponding to

f(t,y(t),y(t - tau_1),...,y(t - tau_k)). In the call to DDEFUN, a scalar T

is the current t, a column vector Y approximates y(t), and a column Z(:,j)

approximates y(t - tau_j) for delay tau_j = LAGS(J). The DDEs are

integrated from T0=TSPAN(1) to TF=TSPAN(end) where T0 < TF. The solution

at t <= T0 is specified by HISTORY in one of three ways: HISTORY can be

a function handle, where for a scalar T, HISTORY(T) returns a column

vector y(t). If y(t) is constant, HISTORY can be this column vector.

If this call to DDE23 continues a previous integration to T0, HISTORY

can be the solution SOL from that call.

DDE23 produces a solution that is continuous on [T0,TF]. The solution is

evaluated at points TINT using the output SOL of DDE23 and the function

DEVAL: YINT = DEVAL(SOL,TINT). The output SOL is a structure with

SOL.x -- mesh selected by DDE23

SOL.y -- approximation to y(t) at the mesh points of SOL.x

SOL.yp -- approximation to y'(t) at the mesh points of SOL.x

SOL.solver -- 'dde23'

SOL = DDE23(DDEFUN,LAGS,HISTORY,TSPAN,OPTIONS) solves as above with default

parameters replaced by values in OPTIONS, a structure created with the

DDESET function. See DDESET for details. Commonly used options are

scalar relative error tolerance 'RelTol' (1e-3 by default) and vector of

absolute error tolerances 'AbsTol' (all components 1e-6 by default).

DDE23 can solve problems with discontinuities in the solution prior to T0

(the history) or discontinuities in coefficients of the equations at known

values of t after T0 if the locations of these discontinuities are

provided in a vector as the value of the 'Jumps' option.

By default the initial value of the solution is the value returned by

HISTORY at T0. A different initial value can be supplied as the value of

the 'InitialY' property.

With the 'Events' property in OPTIONS set to a function handle EVENTS,

DDE23 solves as above while also finding where event functions

g(t,y(t),y(t - tau_1),...,y(t - tau_k)) are zero. For each function

you specify whether the integration is to terminate at a zero and whether

the direction of the zero crossing matters. These are the three column

vectors returned by EVENTS: [VALUE,ISTERMINAL,DIRECTION] = EVENTS(T,Y,Z).

For the I-th event function: VALUE(I) is the value of the function,

ISTERMINAL(I) = 1 if the integration is to terminate at a zero of this

event function and 0 otherwise. DIRECTION(I) = 0 if all zeros are to

be computed (the default), +1 if only zeros where the event function is

increasing, and -1 if only zeros where the event function is decreasing.

The field SOL.xe is a row vector of times at which events occur. Columns

of SOL.ye are the corresponding solutions, and indices in vector SOL.ie

specify which event occurred.

Example

sol = dde23(@ddex1de,[1, 0.2],@ddex1hist,[0, 5]);

solves a DDE on the interval [0, 5] with lags 1 and 0.2 and delay

differential equations computed by the function ddex1de. The history

is evaluated for t <= 0 by the function ddex1hist. The solution is

evaluated at 100 equally spaced points in [0 5]

tint = linspace(0,5);

yint = deval(sol,tint);

and plotted with

plot(tint,yint);

DDEX1 shows how this problem can be coded using subfunctions. For

another example see DDEX2.

Class support for inputs TSPAN, LAGS, HISTORY, and the result of DDEFUN(T,Y,Z):

float: double, single

See also ddeset, ddeget, deval.

Reference page in Help browser

doc dde23

<ddesd> - Solve delay differential equations (DDEs) with variable delays.

DDESD Solve delay differential equations (DDEs) with general delays.

SOL = DDESD(DDEFUN,DELAYS,HISTORY,TSPAN) integrates a system of DDEs

y'(t) = f(t,y(t),y(d(1)),...,y(d(k))). The delays d(j) can depend on

both t and y(t). DDEFUN and DELAYS are function handles. DELAYS(T,Y)

must return a column vector of delays d(j). DDESD imposes the requirement

that d(j) <= t by using min(d(j),t). The function DDEFUN(T,Y,Z) must

return a column vector corresponding to f(t,y(t),y(d(1)),...,y(d(k))).

In the call to DDEFUN and DELAYS, a scalar T is the current t, a column

vector Y approximates y(t), and a column Z(:,j) approximates y(d(j)) for

delay d(j) given as component j of DELAYS(T,Y). The DDEs are integrated

from T0=TSPAN(1) to TF=TSPAN(end) where T0 < TF. The solution at t <= T0

is specified by HISTORY in one of three ways: HISTORY can be a function

handle, where for a scalar T, HISTORY(T) returns the column vector y(t).

If y(t) is constant, HISTORY can be this column vector. If this call to

DDESD continues a previous integration to T0, HISTORY can be the solution

SOL from that call.

DDESD produces a solution that is continuous on [T0,TF]. The solution is

evaluated at points TINT using the output SOL of DDESD and the function

DEVAL: YINT = DEVAL(SOL,TINT). The output SOL is a structure with

SOL.x -- mesh selected by DDESD

SOL.y -- approximation to y(t) at the mesh points of SOL.x

SOL.yp -- approximation to y'(t) at the mesh points of SOL.x

SOL.solver -- 'ddesd'

SOL = DDESD(DDEFUN,DELAYS,HISTORY,TSPAN,OPTIONS) solves as above with

default parameters replaced by values in OPTIONS, a structure created

with the DDESET function. See DDESET for details. Commonly used options

are scalar relative error tolerance 'RelTol' (1e-3 by default) and vector

of absolute error tolerances 'AbsTol' (all components 1e-6 by default).

By default the initial value of the solution is the value returned by

HISTORY at T0. A different initial value can be supplied as the value of

the 'InitialY' property.

With the 'Events' property in OPTIONS set to a function handle EVENTS,

DDESD solves as above while also finding where event functions

g(t,y(t),y(d(1)),...,y(d(k))) are zero. For each function you specify

whether the integration is to terminate at a zero and whether the

direction of the zero crossing matters. These are the three vectors

returned by EVENTS: [VALUE,ISTERMINAL,DIRECTION] = EVENTS(T,Y,Z).

For the I-th event function: VALUE(I) is the value of the function,

ISTERMINAL(I) = 1 if the integration is to terminate at a zero of this

event function and 0 otherwise. DIRECTION(I) = 0 if all zeros are to

be computed (the default), +1 if only zeros where the event function is

increasing, and -1 if only zeros where the event function is decreasing.

The field SOL.xe is a row vector of times at which events occur. Columns

of SOL.ye are the corresponding solutions, and indices in vector SOL.ie

specify which event occurred.

If all the delay functions have the form d(j) = t - tau_j, you can set

the argument DELAYS to a constant vector DELAYS(j) = tau_j. With delay

functions of this form, DDESD is used exactly like DDE23.

Example

sol = ddesd(@ddex1de,@ddex1delays,@ddex1hist,[0, 5]);

solves a DDE on the interval [0, 5] with delays specified by the

function ddex1delays and differential equations computed by ddex1de.

The history is evaluated for t <= 0 by the function ddex1hist.

The solution is evaluated at 100 equally spaced points in [0 5]

tint = linspace(0,5);

yint = deval(sol,tint);

and plotted with

plot(tint,yint);

This problem involves constant delays. The help section of DDE23 and

the example DDEX1 show how this problem can be solved using DDE23.

For more examples of solving delay differential equations see DDEX2

and DDEX3.

Class support for inputs TSPAN, HISTORY, and the results of DELAYS(T,Y)

and DDEFUN(T,Y,Z):

float: double, single

See also dde23, ddeset, ddeget, deval.

Reference page in Help browser

doc ddesd

Boundary value problem solver for ODEs

<bvp4c> - Solve boundary value problems by collocation, 3-stage Lobatto formula.

BVP4C Solve boundary value problems for ODEs by collocation.

SOL = BVP4C(ODEFUN,BCFUN,SOLINIT) integrates a system of ordinary

differential equations of the form y' = f(x,y) on the interval [a,b],

subject to general two-point boundary conditions of the form

bc(y(a),y(b)) = 0. ODEFUN and BCFUN are function handles. For a scalar X

and a column vector Y, ODEFUN(X,Y) must return a column vector representing

f(x,y). For column vectors YA and YB, BCFUN(YA,YB) must return a column

vector representing bc(y(a),y(b)). SOLINIT is a structure with fields

x -- ordered nodes of the initial mesh with

SOLINIT.x(1) = a, SOLINIT.x(end) = b

y -- initial guess for the solution with SOLINIT.y(:,i)

a guess for y(x(i)), the solution at the node SOLINIT.x(i)

BVP4C produces a solution that is continuous on [a,b] and has a

continuous first derivative there. The solution is evaluated at points

XINT using the output SOL of BVP4C and the function DEVAL:

YINT = DEVAL(SOL,XINT). The output SOL is a structure with

SOL.solver -- 'bvp4c'

SOL.x -- mesh selected by BVP4C

SOL.y -- approximation to y(x) at the mesh points of SOL.x

SOL.yp -- approximation to y'(x) at the mesh points of SOL.x

SOL.stats -- computational cost statistics (also displayed when

the 'Stats' option is set with BVPSET).

SOL = BVP4C(ODEFUN,BCFUN,SOLINIT,OPTIONS) solves as above with default

parameters replaced by values in OPTIONS, a structure created with the

BVPSET function. To reduce the run time greatly, use OPTIONS to supply

a function for evaluating the Jacobian and/or vectorize ODEFUN.

See BVPSET for details and SHOCKBVP for an example that does both.

Some boundary value problems involve a vector of unknown parameters p

that must be computed along with y(x):

y' = f(x,y,p)

0 = bc(y(a),y(b),p)

For such problems the field SOLINIT.parameters is used to provide a guess

for the unknown parameters. On output the parameters found are returned

in the field SOL.parameters. The solution SOL of a problem with one set

of parameter values can be used as SOLINIT for another set. Difficult BVPs

may be solved by continuation: start with parameter values for which you can

get a solution, and use it as a guess for the solution of a problem with

parameters closer to the ones you want. Repeat until you solve the BVP

for the parameters you want.

The function BVPINIT forms the guess structure in the most common

situations: SOLINIT = BVPINIT(X,YINIT) forms the guess for an initial

mesh X as described for SOLINIT.x, and YINIT either a constant vector

guess for the solution or a function handle. If YINIT is a function handle

then for a scalar X, YINIT(X) must return a column vector, a guess for

the solution at point x in [a,b]. If the problem involves unknown parameters

SOLINIT = BVPINIT(X,YINIT,PARAMS) forms the guess with the vector PARAMS of

guesses for the unknown parameters.

BVP4C solves a class of singular BVPs, including problems with

unknown parameters p, of the form

y' = S*y/x + f(x,y,p)

0 = bc(y(0),y(b),p)

The interval is required to be [0, b] with b > 0.

Often such problems arise when computing a smooth solution of

ODEs that result from PDEs because of cylindrical or spherical

symmetry. For singular problems the (constant) matrix S is

specified as the value of the 'SingularTerm' option of BVPSET,

and ODEFUN evaluates only f(x,y,p). The boundary conditions

must be consistent with the necessary condition S*y(0) = 0 and

the initial guess should satisfy this condition.

BVP4C can solve multipoint boundary value problems. For such problems

there are boundary conditions at points in [a,b]. Generally these points

represent interfaces and provide a natural division of [a,b] into regions.

BVP4C enumerates the regions from left to right (from a to b), with indices

starting from 1. In region k, BVP4C evaluates the derivative as

YP = ODEFUN(X,Y,K). In the boundary conditions function,

BCFUN(YLEFT,YRIGHT), YLEFT(:,K) is the solution at the 'left' boundary

of region k and similarly for YRIGHT(:,K). When an initial guess is

created with BVPINIT(XINIT,YINIT), XINIT must have double entries for

each interface point. If YINIT is a function handle, BVPINIT calls

Y = YINIT(X,K) to get an initial guess for the solution at X in region k.

In the solution structure SOL returned by BVP4C, SOL.x has double entries

for each interface point. The corresponding columns of SOL.y contain

the 'left' and 'right' solution at the interface, respectively.

See THREEBVP for an example of solving a three-point BVP.

Example

solinit = bvpinit([0 1 2 3 4],[1 0]);

sol = bvp4c(@twoode,@twobc,solinit);

solve a BVP on the interval [0,4] with differential equations and

boundary conditions computed by functions twoode and twobc, respectively.

This example uses [0 1 2 3 4] as an initial mesh, and [1 0] as an initial

approximation of the solution components at the mesh points.

xint = linspace(0,4);

yint = deval(sol,xint);

evaluate the solution at 100 equally spaced points in [0 4]. The first

component of the solution is then plotted with

plot(xint,yint(1,:));

For more examples see TWOBVP, FSBVP, SHOCKBVP, MAT4BVP, EMDENBVP, THREEBVP.

See also bvp5c, bvpset, bvpget, bvpinit, bvpxtend, deval, function_handle.

Reference page in Help browser

doc bvp4c

<bvp5c> - Solve boundary value problems by collocation, 4-stage Lobatto formula.

BVP5C Solve boundary value problems for ODEs by collocation.

SOL = BVP5C(ODEFUN,BCFUN,SOLINIT) integrates a system of ordinary

differential equations of the form y' = f(x,y) on the interval [a,b],

subject to general two-point boundary conditions of the form

bc(y(a),y(b)) = 0. ODEFUN and BCFUN are function handles. For a scalar X

and a column vector Y, ODEFUN(X,Y) must return a column vector representing

f(x,y). For column vectors YA and YB, BCFUN(YA,YB) must return a column

vector representing bc(y(a),y(b)). SOLINIT is a structure with fields

x -- ordered nodes of the initial mesh with

SOLINIT.x(1) = a, SOLINIT.x(end) = b

y -- initial guess for the solution with SOLINIT.y(:,i)

a guess for y(x(i)), the solution at the node SOLINIT.x(i)

BVP5C produces a solution that is continuous on [a,b] and has a

continuous first derivative there. The solution is evaluated at points

XINT using the output SOL of BVP5C and the function DEVAL:

YINT = DEVAL(SOL,XINT). The output SOL is a structure with

SOL.solver -- 'bvp5c'

SOL.x -- mesh selected by BVP5C

SOL.y -- approximation to y(x) at the mesh points of SOL.x

SOL.stats -- computational cost statistics (also displayed when

the 'Stats' option is set with BVPSET).

SOL = BVP5C(ODEFUN,BCFUN,SOLINIT,OPTIONS) solves as above with default

parameters replaced by values in OPTIONS, a structure created with the

BVPSET function. To reduce the run time greatly, use OPTIONS to supply

a function for evaluating the Jacobian and/or vectorize ODEFUN.

See BVPSET for details and SHOCKBVP for an example that does both.

Some boundary value problems involve a vector of unknown parameters p

that must be computed along with y(x):

y' = f(x,y,p)

0 = bc(y(a),y(b),p)

For such problems the field SOLINIT.parameters is used to provide a guess

for the unknown parameters. On output the parameters found are returned

in the field SOL.parameters. The solution SOL of a problem with one set

of parameter values can be used as SOLINIT for another set. Difficult BVPs

may be solved by continuation: start with parameter values for which you can

get a solution, and use it as a guess for the solution of a problem with

parameters closer to the ones you want. Repeat until you solve the BVP

for the parameters you want.

The function BVPINIT forms the guess structure in the most common

situations: SOLINIT = BVPINIT(X,YINIT) forms the guess for an initial

mesh X as described for SOLINIT.x, and YINIT either a constant vector

guess for the solution or a function handle. If YINIT is a function handle

then for a scalar X, YINIT(X) must return a column vector, a guess for

the solution at point x in [a,b]. If the problem involves unknown parameters

SOLINIT = BVPINIT(X,YINIT,PARAMS) forms the guess with the vector PARAMS of

guesses for the unknown parameters.

BVP5C solves a class of singular BVPs, including problems with

unknown parameters p, of the form

y' = S*y/x + f(x,y,p)

0 = bc(y(0),y(b),p)

The interval is required to be [0, b] with b > 0.

Often such problems arise when computing a smooth solution of

ODEs that result from PDEs because of cylindrical or spherical

symmetry. For singular problems the (constant) matrix S is

specified as the value of the 'SingularTerm' option of BVPSET,

and ODEFUN evaluates only f(x,y,p). The boundary conditions

must be consistent with the necessary condition S*y(0) = 0 and

the initial guess should satisfy this condition.

BVP5C can solve multipoint boundary value problems. For such problems

there are boundary conditions at points in [a,b]. Generally these points

represent interfaces and provide a natural division of [a,b] into regions.

BVP5C enumerates the regions from left to right (from a to b), with indices

starting from 1. In region k, BVP5C evaluates the derivative as

YP = ODEFUN(X,Y,K). In the boundary conditions function,

BCFUN(YLEFT,YRIGHT), YLEFT(:,K) is the solution at the 'left' boundary

of region k and similarly for YRIGHT(:,K). When an initial guess is

created with BVPINIT(XINIT,YINIT), XINIT must have double entries for

each interface point. If YINIT is a function handle, BVPINIT calls

Y = YINIT(X,K) to get an initial guess for the solution at X in region k.

In the solution structure SOL returned by BVP5C, SOL.x has double entries

for each interface point. The corresponding columns of SOL.y contain

the 'left' and 'right' solution at the interface, respectively.

See THREEBVP for an example of solving a three-point BVP.

Example

solinit = bvpinit([0 1 2 3 4],[1 0]);

sol = bvp5c(@twoode,@twobc,solinit);

solve a BVP on the interval [0,4] with differential equations and

boundary conditions computed by functions twoode and twobc, respectively.

This example uses [0 1 2 3 4] as an initial mesh, and [1 0] as an initial

approximation of the solution components at the mesh points.

xint = linspace(0,4);

yint = deval(sol,xint);

evaluate the solution at 100 equally spaced points in [0 4]. The first

component of the solution is then plotted with

plot(xint,yint(1,:));

For more examples see FSBVP, SHOCKBVP, MAT4BVP, EMDENBVP. To use the

BVP5C solver, you must pass 'bvp5c' as input argument:

fsbvp('bvp5c')

BVP5C is used exactly like BVP4C, but error tolerances do not mean the

same in the two solvers. If S(x) approximates the solution y(x), BVP4C

controls the residual |S'(x) - f(x,S(x))|. This controls indirectly the

true error |y(x) - S(x)|. BVP5C controls the true error directly.

BVP5C is more efficient than BVP4C for small error tolerances.

See also bvp4c, bvpset, bvpget, bvpinit, bvpxtend, deval, function_handle.

Reference page in Help browser

doc bvp5c

Соседние файлы в папке Библиотеки Matlab