XLPack 6.1
Python API Reference Manual
Loading...
Searching...
No Matches

◆ dfmin()

def dfmin ( ,
,
,
tol  = 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 (float):
Abscissa approximating the point where f(x) attains a minimum on the interval [a, b].

info (int):
= 0: Normal return
= -1: The argument f is invalid
Parameters
[in]aLeft endpoint of initial interval.
[in]bRight endpoint of initial interval.
[in]fUser supplied function, which evaluates f(x) defined as follows: _CODE def f(x): return computed function value f(x) _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].
f(x) = x^3 - 2x - 5
def f(x):
return x**3 - 2*x - 5
def TestDfmin():
a = 0.0
b = 2.0
x, info = dfmin(a, b, f)
print(x, info)
def dfmin(a, b, f, tol=1.0e-10)
Minimum of a single variable general nonlinear function
Example Results
>>> TestDfmin()
0.8164965876303981 0