|
|
◆ Dfmin_r()
| Sub Dfmin_r |
( |
A As |
Double, |
|
|
B As |
Double, |
|
|
Tol As |
Double, |
|
|
XX As |
Double, |
|
|
YY As |
Double, |
|
|
IRev As |
Long |
|
) |
| |
Minimum of a single variable general nonlinear function (reverse communication version)
- Purpose
- This routine finds a minimum of a function f(x) between the given values A and B.
The method used is a combination of golden section search and successive parabolic interpolation. Convergence is never much slower than that for a Fibonacci search. If the function f has a continuous second derivative which is positive at the minimum (which is not at A or B), then convergence is superlinear, and usually of the order of about 1.324....
The function f is never evaluated at two points closer together than eps*abs(Dfmin) + (Tol/3), where eps is approximately the square root of the relative machine precision. If f is a unimodal function and the computed values of f are always unimodal when separated by at least eps*abs(xstar) + (Tol/3), then Dfmin approximates the abscissa of the global minimum of f on the interval [A, B] with an error less than 3*eps*abs(Dfmin) + Tol. If f is not unimodal, then Dfmin may approximate a local, but perhaps non-global, minimum to the same accuracy.
- Parameters
-
| [in] | A | Left endpoint of initial interval. |
| [in] | B | Right endpoint of initial interval. |
| [in] | Tol | Desired length of the interval of uncertainty of the final result. (Tol >= 0) |
| [out] | XX | IRev = 0: The abscissa approximating the point where f(x) attains a minimum on the interval [A, B].
IRev = 1: The abscissa where the function value shoule be evaluated and given in the next call. |
| [in] | YY | IRev = 1: The function value f(XX) should be given in YY in the next call. |
| [in,out] | IRev | Control variable for reverse communication.
[in] Before first call, IRev should be initialized to zero. On succeeding calls, IRev should not be altered.
[out] If IRev is not zero, set the required values to the specified variables as follows and call the routine again.
= 0: Computation finished.
= 1: User should set the function value at XX (f(XX)) in YY. Do not alter any variables other than YY. |
- Reference
- D. Kahaner, C. Moler, S. Nash, "Numerical Methods and Software", Prentice-Hall (1989)
- Example Program
- Find the minimum point of the following function in the interval [0, 2].
Function FDfmin(X As Double) As Double
FDfmin = X ^ 3 - 2 * X - 5
End Function
Sub Ex_Dfmin_r()
Dim A As Double, B As Double, Tol As Double
Dim XX As Double, YY As Double, IRev As Long
A = 0: B = 2
Tol = 0.0000000001 '1.0e-10
IRev = 0
Do
Call Dfmin_r(A, B, Tol, XX, YY, IRev)
If IRev <> 0 Then YY = FDfmin(XX)
Loop While IRev <> 0
Debug.Print "X =", XX
End Sub
Sub Dfmin_r(A As Double, B As Double, Tol As Double, XX As Double, YY As Double, IRev As Long) Minimum of a single variable general nonlinear function (reverse communication version)
- Example Results
-
|