You are here: Symbol Reference > Optimization Namespace > Functions > Optimization.MinBrent Function
MtxVec VCL
ContentsIndex
PreviousUpNext
Optimization.MinBrent Function

Minimizes single variable function.

Pascal
function MinBrent(ax: double; bx: double; Func: TRealFunction; const FloatPrecision: TMtxFloatPrecision; Const Consts: array of double; Const ObjConst: Array of TObject; out MinX: double; MaxIter: integer; Accuracy: double = 1.0E-8; const Verbose: TStrings = nil): Integer; overload;
Parameters 
Description 
ax 
Defines initial lower limit for minimum search. 
bx 
Defines initial uššer limit for minimum search. 
Func 
Real functin of single variable (must be of TRealFunction type) to be minimized. 
FloatPrecision 
Specifies the floating point precision to be used by the routine. 
Consts 
Additional Fun constant parameters (can be/is usually nil).  
ObjConst 
Additional Fun constant parameters (can be/is usually nil). 
MinX 
Returns the position of function minimum. 
MaxIter 
Maximum allowed numer of minimum search iterations. 
Accuracy 
Desired minimum position tolerance. 
Verbose 
If assigned, stores Func, evaluated at each iteration step. Optionally, you can also pass TOptControl object to the Verbose parameter. This allows the optimization procedure to be interrupted from another thread and optionally also allows logging and iteration count monitoring. 

the number of iterations required to reach the solution(minimum) within given tolerance.

Minimizes the function of one variable. This routine uses slightly modified version of the algol 60 procedure localmin, introduced by Richard Brent.

Problem: Find the minimum of the function of single variable by using the Brent method. 

Solution:The function is defined by the following equation: 

 

 

Uses MtxVec, Math387, Optimization; function Fun(const Pars: TVec: const Consts: TVec; const ObjConsts: Array of TObject): double; begin Fun := Sin(Pars[0])+Sqr(Pars[0]+2); // note that Pars holds only one variable ! end; procedure Example; var Res,x : double; begin // initial estimates for x1 and x2 Res := MinBrent(-10,10,Fun,mvDouble,[],[],x,500,1e-8); // stop if Iters >500 or Tolerance < 1e-8 // Returns Res = -1.8582461797 end;
#include "MtxExpr.hpp" #include "Math387.hpp" #include "Optimization.hpp" double __fastcall Fun(TVec * const x, TVec* const c, System::TObject* const * o, const int o_Size) { double* X = x->PValues(0); return Sin(X[0])+IntPower(X[0]+2,2); // note that Pars holds only one variable ! } void __fastcall Example(); { // initial estimates for x1 and x2 double x; int iter = MinBrent(-10,10,Fun,mvDouble,NULL,-1,NULL,-1,x,500,1.0E-8,NULL); // stop if Iters >500 or Tolerance < 1e-8 // returns res = -1.8582461797 }
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!