c05av attempts to locate an interval containing a simple zero of a continuous function using a binary search. It uses reverse communication for evaluating the function.
Syntax
C# |
---|
public static void c05av( ref double x, double fx, ref double h, double boundl, double boundu, ref double y, double[] c, ref int ind, out int ifail ) |
Visual Basic |
---|
Public Shared Sub c05av ( _ ByRef x As Double, _ fx As Double, _ ByRef h As Double, _ boundl As Double, _ boundu As Double, _ ByRef y As Double, _ c As Double(), _ ByRef ind As Integer, _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void c05av( double% x, double fx, double% h, double boundl, double boundu, double% y, array<double>^ c, int% ind, [OutAttribute] int% ifail ) |
F# |
---|
static member c05av : x : float byref * fx : float * h : float byref * boundl : float * boundu : float * y : float byref * c : float[] * ind : int byref * ifail : int byref -> unit |
Parameters
- x
- Type: System..::..Double%On initial entry: the best available approximation to the zero.Constraint: x must lie in the closed interval (see below).On intermediate exit: contains the point at which must be evaluated before re-entry to the method.
- fx
- Type: System..::..DoubleOn intermediate re-entry: must contain for the current value of x.
- h
- Type: System..::..Double%On initial entry: a basic step size which is used in the binary search for an interval containing a zero. The basic step sizes , and are used in turn when searching for the zero.Constraint: either or must lie inside the closed interval .h must be sufficiently large that on the computer.On final exit: is undefined.
- boundl
- Type: System..::..DoubleOn initial entry: boundl and boundu must contain respectively lower and upper bounds for the interval of search for the zero.Constraint: .
- boundu
- Type: System..::..DoubleOn initial entry: boundl and boundu must contain respectively lower and upper bounds for the interval of search for the zero.Constraint: .
- y
- Type: System..::..Double%On initial entry: need not be set.
- c
- Type: array<System..::..Double>[]()[][]An array of size []On initial entry: need not be set.On final exit: if or , contains .
- ind
- Type: System..::..Int32%On intermediate exit: contains or . The calling program must evaluate at x, storing the result in fx, and re-enter c05av with all other parameters unchanged.On final exit: contains .Constraint: on entry , , or .
- ifail
- Type: System..::..Int32%On initial entry: ifail must be set to , . If you are unfamiliar with this parameter you should refer to Library Overview for details.For environments where it might be inappropriate to halt program execution when an error is detected, the value is recommended. If the output of error messages is undesirable, then the value is recommended. Otherwise, because for this method the values of the output parameters may be useful even if on exit, the recommended value is . When the value is used it is essential to test the value of ifail on exit.On final exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
You must supply an initial point x and a step h. c05av attempts to locate a short interval containing a simple zero of .
References
None.
Error Indicators and Warnings
Errors or warnings detected by the method:
On entry, , or , or both and .
- The parameter ind is incorrectly set on initial or intermediate entry.
Accuracy
c05av is not intended to be used to obtain accurate approximations to the zero of but rather to locate an interval containing a zero. This interval can then be used as input to an accurate rootfinder such as c05ay or c05az. The size of the interval determined depends somewhat unpredictably on the choice of x and h. The closer x is to the root and the smaller the initial value of h, then, in general, the smaller (more accurate) the interval determined; however, the accuracy of this statement depends to some extent on the behaviour of near and on the size of h.
Parallelism and Performance
None.
Further Comments
For most problems, the time taken on each call to c05av will be negligible compared with the time spent evaluating between calls to c05av. However, the initial value of x and h will clearly affect the timing. The closer x is to the root, and the larger the initial value of h then the less time taken. (However taking a large h can affect the accuracy and reliability of the method, see below.)
You are expected to choose boundl and boundu as physically (or mathematically) realistic limits on the interval of search. For example, it may be known, from physical arguments, that no zero of of interest will lie outside . Alternatively, may be more expensive to evaluate for some values of x than for others and such expensive evaluations can sometimes be avoided by careful choice of boundl and boundu.
The choice of boundl and boundu affects the search only in that these values provide physical limitations on the search values and that the search is terminated if it seems, from the available information about , that the zero lies outside . In this case ( on exit), only one of and may have been evaluated and a zero close to the other end of the interval could be missed. The actual interval searched is returned in the parameters x and y and you can call c05av again to search the remainder of the original interval.
Though c05av is intended primarily for determining an interval containing a zero of , it may be used to shorten a known interval. This could be useful if, for example, a large interval containing the zero is known and it is also known that the root lies close to one end of the interval; by setting x to this end of the interval and h small, a short interval will usually be determined. However, it is worth noting that once any interval containing a zero has been determined, a call to c05az will usually be the most efficient way to calculate an interval of specified length containing the zero. To assist in this determination, the information in fx and in x, y and on successful exit from c05av is in the correct form for a call to method c05az with .
Example
This example finds a sub-interval of containing a simple zero of . The zero nearest to is required and so we set initially.