Tfmin
From TomWiki
Jump to navigationJump to search
Purpose
Minimize function of one variable. Find miniumum x in [x_L, x_U] for function Func within tolerance xTol. Solves using Brents minimization algorithm.
Calling Syntax
[x, nFunc] = Tfmin(Func, x_L, x_U, xTol, Prob)
Inputs
Variable | Description |
---|---|
Func | Function of x to be minimized. Func must be defined as:
f = Func(x) if no 5th argument Prob is given or f = Func(x, Prob) if 5th argument Prob is given. |
x_L | Lower bound on x. |
x_U | Upper bound on x. |
xTol | Tolerance on accuracy of minimum. |
Prob | Structure (or any Matlab variable) sent to Func. If many parameters are to be sent to Func set them in Prob as a structure. Example for parameters a and b:
Prob.user.a = a; Prob.user.b = b; [x, nFunc] = Tfmin('myFunc',0,1,1E-5,Prob); In myFunc: function f = myFunc(x, Prob) a = Prob.user.a; b = Prob.user.b; f = "matlab expression dependent of x, a and b"; |
Outputs
Variable | Description |
---|---|
x | Solution. |
nFunc | Number of calls to Func. |