naginterfaces.library.opt.one_​var_​deriv

naginterfaces.library.opt.one_var_deriv(funct, e1, e2, a, b, maxcal, data=None)[source]

one_var_deriv searches for a minimum, in a given finite interval, of a continuous function of a single variable, using function and first derivative values. The method (based on cubic interpolation) is intended for functions which have a continuous first derivative (although it will usually work if the derivative has occasional discontinuities).

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

https://support.nag.com/numeric/nl/nagdoc_30.1/flhtml/e04/e04bbf.html

Parameters
functcallable (fc, gc) = funct(xc, data=None)

You must supply this function to calculate the values of and at any point in .

It should be tested separately before being used in conjunction with one_var_deriv.

Parameters
xcfloat

The point at which the values of and are required.

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
fcfloat

Must be set to the value of the function at the current point .

gcfloat

Must be set to the value of the first derivative at the current point .

e1float

The relative accuracy to which the position of a minimum is required. (Note that, since is a relative tolerance, the scaling of is automatically taken into account.)

should be no smaller than , and preferably not much less than , where is the machine precision.

e2float

The absolute accuracy to which the position of a minimum is required. should be no smaller than .

afloat

The lower bound of the interval containing a minimum.

bfloat

The upper bound of the interval containing a minimum.

maxcalint

The maximum number of calls of to be allowed.

dataarbitrary, optional

User-communication data for callback functions.

Returns
e1float

If you set to (or to any value less than ), will be reset to the default value before starting the minimization process.

e2float

If you set to (or to any value less than ), will be reset to the default value .

afloat

An improved lower bound on the position of the minimum.

bfloat

An improved upper bound on the position of the minimum.

maxcalint

The total number of times that was actually called.

xfloat

The estimated position of the minimum.

ffloat

The function value at the final point given in .

gfloat

The value of the first derivative at the final point in .

Warns
NagAlgorithmicWarning
(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

The maximum number of function calls, , have been performed. This may have happened simply because was set too small for the particular problem, or may be due to a mistake in the user-supplied function . If no mistake can be found in , restart one_var_deriv (preferably with the values of and given on exit from the previous call to one_var_deriv).

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.

one_var_deriv is applicable to problems of the form:

when the first derivative can be calculated. The function normally computes a sequence of values which tend in the limit to a minimum of subject to the given bounds. It also progressively reduces the interval in which the minimum is known to lie. It uses the safeguarded cubic-interpolation method described in Gill and Murray (1973).

You must supply a to evaluate and . The arguments and together specify the accuracy

to which the position of the minimum is required. Note that is never called at a point which is closer than to a previous point.

If the original interval contains more than one minimum, one_var_deriv will normally find one of the minima.

References

Gill, P E and Murray, W, 1973, Safeguarded steplength algorithms for optimization using descent methods, NPL Report NAC 37, National Physical Laboratory