BFGS
Updated 2024-03-01 22:07:59.877000
Syntax
SELECT [westclintech].[wct].[BFGS] (
<@Func, nvarchar(max),>
,<@VarNames, nvarchar(4000),>
,<@X, nvarchar(4000),>
,<@H, float,>
,<@tol, float,>)
Description
Use the scalar function BFGS to find the minimum of a functions using the Broyden-Fletcher-Goldfarb-Shanno (BFGS) method.
Arguments
@tol
Tolerance (for the solution).
@H
Step size.
@VarNames
The name of the variable.
@X
The starting point for the minimization.
@Func
The function to be evaluated, as a string. The function must be in the form of a SELECT statement.
Return Type
nvarchar(max)
Remarks
If Func returns a NULL then NULL Is returned.
If Func is not a valid SELECT statement then NULL is returned.
If no solution is found then NULL is returned.
If X is NULL then @X = ''.
If H is NULL then H = 0.
If H <= 0 then H = 2^(-52).
If tol is NULL then tol = 0.0001
Examples
Example #1
Calculate the minimum of
e^{x_1-1}+e^{-x_2+1}+\left(x_1-x_2\right)^2
Our initial estimate is the point (0,0). Since the result is returned as a string, we will use the MATRIX function to unpack the results into a vector format.
SELECT *
FROM wct.MATRIX(wct.BFGS('SELECT EXP(@x1-1) + EXP(-@x2+1) + POWER(@x1 -
@x2,2)', '@x1,@x2', '0,0', NULL, NULL));
This produces the following result.
{"columns":[{"field":"RowNum","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"ColNum","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"ItemValue","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"RowNum":"0","ColNum":"0","ItemValue":"0.796112971274252"},{"RowNum":"1","ColNum":"0","ItemValue":"1.20388757388411"}]}
See Also
BRENT - Find the root of a continuous function of on variable
HESSIAN - Numerically computer the Hessian matrix
JACOBIAN - Numerically compute the Jacobian matrix
NEWTON - Find the root of a univariate function
SECANT - Find the root of single-variable continuous function.