Tfmin: Difference between revisions
From TomWiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[Category:Solvers]] | |||
==Purpose== | ==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 | 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== | ==Calling Syntax== | ||
<source lang="matlab"> | |||
[x, nFunc] = Tfmin(Func, x_L, x_U, xTol, Prob) | [x, nFunc] = Tfmin(Func, x_L, x_U, xTol, Prob) | ||
</source> | |||
== | ==Inputs== | ||
{| | {| class="wikitable" | ||
!''Variable''||Description | |||
|- | |-valign="top" | ||
|''Func''||Function of x to be minimized. Func must be defined as: | |''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_L''||Lower bound on x. | ||
Line 25: | Line 29: | ||
|-valign="top" | |-valign="top" | ||
|''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''||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== | ||
{| | {| class="wikitable" | ||
!''Variable''||Description | |||
|- | |- | ||
|''x''||Solution. | |''x''||Solution. |
Latest revision as of 08:07, 10 January 2012
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. |