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

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 }
Copyright (c) 1999-2025 by Dew Research. All rights reserved.