Tfmin: Difference between revisions

From TomWiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
[[Category:Solvers]]
[[Category:Solvers]]
{{cleanup|Clean this article.}}


==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. Reference: "Computer Methods for Mathematical Computations", Forsythe, Malcolm, and Moler, Prentice-Hall, 1976.
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>


===Description  of Inputs===
==Inputs==


{|
{| class="wikitable"
|''Variable''||Description
!''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) if no 5th argument Prob is given or
|-
 
|||f = Func(x, Prob) if 5th argument Prob is given.
f = Func(x, Prob) if 5th argument Prob is given.
|-
|-
|''x_L''||Lower bound on x.
|''x_L''||Lower bound on x.
Line 28: 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;
Prob.user.a = a; Prob.user.b = b;
|-
 
|||[x, nFunc] = Tfmin('myFunc',0,1,1E-5,Prob); In myFunc:
[x, nFunc] = Tfmin('myFunc',0,1,1E-5,Prob);  
|-
 
|||function f = myFunc(x, Prob)
In myFunc:
|-
 
|||a = Prob.user.a;
function f = myFunc(x, Prob)
|-
 
|||b = Prob.user.b;
a = Prob.user.a;
|-
 
|||f = "matlab expression dependent of x, a and b";
b = Prob.user.b;
 
f = "matlab expression dependent of x, a and b";
|}
|}


===Description  of Outputs===
==Outputs==


{|
{| class="wikitable"
|''Variable''||Description
!''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.