|
|
◆ dfmin()
| function dfmin |
( |
a::Real |
, |
|
|
b::Real |
, |
|
|
f::Function |
, |
|
|
tol::Real |
= 1.0e-10 |
|
) |
| |
Minimum of a single variable general nonlinear function
- Purpose
- dfmin 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 abcissa 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.
- Returns
- (x, info)
x (Float64):
Abscissa approximating the point where f(x) attains a minimum on the interval [a, b].
info (Int32):
= 0: Normal return
= -1: The argument f is invalid
- Parameters
-
| [in] | a | Left endpoint of initial interval. |
| [in] | b | Right endpoint of initial interval. |
| [in] | f | User supplied function, which evaluates f(x) defined as follows: _CODE function f(x) returns computed function value f(x). end _ENDCODE |
| [in] | tol | (Optional)
Desired length of the interval of uncertainty of the final result. (tol >= 0) (default = 1.0e-10) |
- 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 TestDfmin()
f(x) = x^3 - 2*x - 5
a = 0.0
b = 2.0
println(x)
end
function dfmin(a::Real, b::Real, f::Function, tol::Real=1.0e-10) Minimum of a single variable general nonlinear function
- Example Results
> TestDfmin()
0.8164965876303981
|