naginterfaces.library.ode.bvp_​fd_​nonlin_​gen

naginterfaces.library.ode.bvp_fd_nonlin_gen(np, numbeg, nummix, tol, init, x, y, fcn, g, ijac, deleps, itrace, comm, jacobf=None, jacobg=None, jaceps=None, jacgep=None, data=None, io_manager=None, spiked_sorder='C')[source]

bvp_fd_nonlin_gen solves a two-point boundary value problem with general boundary conditions for a system of ordinary differential equations, using a deferred correction technique and Newton iteration.

For full information please refer to the NAG Library document for d02ra

https://www.nag.com/numeric/nl/nagdoc_28.5/flhtml/d02/d02raf.html

Parameters
npint

Must be set to the number of points to be used in the initial mesh.

numbegint

The number of left-hand boundary conditions (that is the number involving only).

nummixint

The number of coupled boundary conditions (that is the number involving both and ).

tolfloat

A positive absolute error tolerance. If

is the final mesh, is the th component of the approximate solution at , and is the th component of the true solution of (1) and (2), then, except in extreme circumstances, it is expected that

initint

Indicates whether you wish to supply an initial mesh and approximate solution () or whether default values are to be used, ().

xfloat, array-like, shape

You must set and . If on entry a default equispaced mesh will be used, otherwise you must specify a mesh by setting , for .

yfloat, array-like, shape

If , need not be set.

If , the array must contain an initial approximation to the solution such that contains an approximation to

fcncallable f = fcn(x, eps, y, data=None)

must evaluate the functions (i.e., the derivatives ) at a general point for a given value of , the continuation parameter (see Notes).

Parameters
xfloat

, the value of the independent variable.

epsfloat

, the value of the continuation parameter. This is if continuation is not being used.

yfloat, ndarray, shape

, for , the values of the dependent variables at .

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
ffloat, array-like, shape

The values of the derivatives evaluated at given , for .

gcallable bc = g(eps, ya, yb, data=None)

must evaluate the boundary conditions in equation (3) and place them in the array .

Parameters
epsfloat

, the value of the continuation parameter. This is if continuation is not being used.

yafloat, ndarray, shape

The value , for .

ybfloat, ndarray, shape

The value , for .

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
bcfloat, array-like, shape

The values , for . These must be ordered as follows:

  1. first, the conditions involving only (see );

  2. next, the coupled conditions involving both and (see ); and,

  3. finally, the conditions involving only ().

ijacint

Indicates whether or not you are supplying Jacobian evaluation functions.

You must supply and and also, when continuation is used, and .

Numerical differentiation is used to calculate the Jacobian and None may be used for the respective callbacks.

delepsfloat

Must be given a value which specifies whether continuation is required. If or then it is assumed that continuation is not required. If then it is assumed that continuation is required unless when an error exit is taken. is used as the increment (see (4)) and the choice is recommended.

itraceint

If warning messages be suppressed, otherwise warning messages will be printed (see Exceptions).

commdict, communication object, modified in place

Communication structure.

On initial entry: need not be set.

jacobfNone or callable f = jacobf(x, eps, y, data=None), optional

Note: if this argument is None then a NAG-supplied facility will be used.

evaluates the Jacobian , for , for , given and , for .

If , numerical differentiation is used to calculate the Jacobian.

Parameters
xfloat

, the value of the independent variable.

epsfloat

, the value of the continuation parameter. This is if continuation is not being used.

yfloat, ndarray, shape

, for , the values of the dependent variables at .

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
ffloat, array-like, shape

must be set to the value of , evaluated at the point , for , for .

jacobgNone or callable (aj, bj) = jacobg(eps, ya, yb, data=None), optional

Note: if this argument is None then a NAG-supplied facility will be used.

evaluates the Jacobians and .

The ordering of the rows of and must correspond to the ordering of the boundary conditions described in the specification of .

If , numerical differentiation is used to calculate the Jacobian.

Parameters
epsfloat

, the value of the continuation parameter. This is if continuation is not being used.

yafloat, ndarray, shape

The value , for .

ybfloat, ndarray, shape

The value , for .

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
ajfloat, array-like, shape

must be set to the value , for , for .

bjfloat, array-like, shape

must be set to the value , for , for .

jacepsNone or callable f = jaceps(x, eps, y, data=None), optional

Note: if this argument is None then a NAG-supplied facility will be used.

evaluates the derivative given and if continuation is being used.

Parameters
xfloat

, the value of the independent variable.

epsfloat

, the value of the continuation parameter.

yfloat, ndarray, shape

The solution values , for , at the point .

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
ffloat, array-like, shape

must contain the value at the point , for .

jacgepNone or callable bcep = jacgep(eps, ya, yb, data=None), optional

Note: if this argument is None then a NAG-supplied facility will be used.

evaluates the derivatives if continuation is being used.

Parameters
epsfloat

, the value of the continuation parameter.

yafloat, ndarray, shape

The value of , for .

ybfloat, ndarray, shape

The value of , for .

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
bcepfloat, array-like, shape

must contain the value of , for .

dataarbitrary, optional

User-communication data for callback functions.

io_managerFileObjManager, optional

Manager for I/O in this routine.

spiked_sorderstr, optional

If is spiked (i.e., has unit extent in all but one dimension, or has size ), selects the storage order to associate with it in the NAG Engine:

spiked_sorder =

row-major storage will be used;

spiked_sorder =

column-major storage will be used.

Two-dimensional arrays returned from callback functions in this routine must then use the same storage order.

Returns
npint

The number of points in the final mesh.

xfloat, ndarray, shape

define the final mesh (with the returned value of ) and and .

yfloat, ndarray, shape

The approximate solution satisfying (5) on the final mesh, that is

where is the number of points in the final mesh. If an error has occurred then contains the latest approximation to the solution. The remaining columns of are not used.

abtfloat, ndarray, shape

, for , holds the largest estimated error (in magnitude) of the th component of the solution over all mesh points.

delepsfloat

An overestimate of the increment (in fact the value of the increment which would have been tried if the restriction had not been imposed). If continuation was not requested then .

If continuation is not requested then and may each be replaced by None.

Raises
NagValueError
(errno )

On entry the mesh points are not in strictly ascending order.

For , mesh point , but mesh point .

(errno )

On entry, , and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

A finer mesh is required for the accuracy requested; that is, is not large enough.

(errno )

The Newton iteration has failed to converge.

This could be due to there being too few points in the initial mesh or to the initial approximate solution being too inaccurate.

If this latter reason is suspected or you cannot make changes to prevent this error, you should use the function with a continuation facility instead.

(errno )

The Jacobian for the boundary conditions is singular.

This may occur due to faulty coding of the Jacobian or, in some circumstances, to a zero initial choice of approximate solution.

(errno )

There is no dependence on the continuation parameter when continuation is being used. This can be due to faulty coding of derivatives with respect to the continuation parameter or to a zero initial choice of approximate solution.

(errno )

The continuation step is required to be less than machine precision for continuation to proceed. It is likely that either the problem has no solution for some value of the continuation parameter near the current value or that the problem is so difficult that even with continuation it is unlikely to be solved using this function. In the latter case using more mesh points initially may help.

(errno )

A serious error occurred in a call to the internal integrator.

The error code internally was .

Please contact NAG.

(errno )

A continuation error occurred, but continuation is not being used.

Please contact NAG.

Warns
NagAlgorithmicWarning
(errno )

Newton iteration has reached round-off level.

If desired accuracy has not been reached, is too small for this problem and this machine precision.

Notes

In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.

bvp_fd_nonlin_gen solves a two-point boundary value problem for a system of ordinary differential equations in the interval with . The system is written in the form

and the derivatives are evaluated by . With the differential equations (1) must be given a system of (nonlinear) boundary conditions

where

The functions are evaluated by . The solution is computed using a finite difference technique with deferred correction allied to a Newton iteration to solve the finite difference equations. The technique used is described fully in Pereyra (1979).

You must supply an absolute error tolerance and may also supply an initial mesh for the finite difference equations and an initial approximate solution (alternatively a default mesh and approximation are used). The approximate solution is corrected using Newton iteration and deferred correction. Then, additional points are added to the mesh and the solution is recomputed with the aim of making the error everywhere less than your tolerance and of approximately equidistributing the error on the final mesh. The solution is returned on this final mesh.

If the solution is required at a few specific points then these should be included in the initial mesh. If, on the other hand, the solution is required at several specific points then you should use the interpolation functions provided in submodule interp if these points do not themselves form a convenient mesh.

The Newton iteration requires Jacobian matrices

These may be supplied through for and for the others. Alternatively the Jacobians may be calculated by numerical differentiation using the algorithm described in Curtis et al. (1974).

For problems of the type (1) and (2) for which it is difficult to determine an initial approximation from which the Newton iteration will converge, a continuation facility is provided. You must set up a family of problems

where etc., and where is a continuation parameter. The choice must give a problem (3) which is easy to solve and must define the problem whose solution is actually required. The function solves a sequence of problems with values

The number and the values are chosen by the function so that each problem can be solved using the solution of its predecessor as a starting approximation. Jacobians and are required and they may be supplied by you via and respectively or may be computed by numerical differentiation.

References

Curtis, A R, Powell, M J D and Reid, J K, 1974, On the estimation of sparse Jacobian matrices, J. Inst. Maths. Applics. (13), 117–119

Pereyra, V, 1979, PASVA3: An adaptive finite-difference Fortran program for first order nonlinear, ordinary boundary problems, Codes for Boundary Value Problems in Ordinary Differential Equations. Lecture Notes in Computer Science, (eds B Childs, M Scott, J W Daniel, E Denman and P Nelson) (76), Springer–Verlag