Logo

HESSIAN

Updated 2024-03-06 16:09:45.447000

Syntax

SELECT [westclintech].[wct].[HESSIAN] (
   <@Func, nvarchar(max),>
  ,<@VarNames, nvarchar(4000),>
  ,<@X, nvarchar(4000),>
  ,<@H, float,>)

Description

Use the scalar function HESSIAN to numerically compute the Hessian matrix. HESSIAN assumes that the function has continuous partial derivatives. HESSIAN produces a square matrix of second order partial derivatives of a scalar function.

\textbf{H}_f\left(x_1,x_2,\dots,x_n\right)=\begin{bmatrix}\frac{\partial^2f}{\partial{x}_1^2}&\frac{\partial^2f}{\partial{x}_1\partial{x}_2}&\frac{\partial^2f}{\partial{x}_1\partial{x}_3}&\dots&\frac{\partial^2f}{\partial{x}_1\partial{x}_n}\\\\\frac{\partial^2f}{\partial{x}_2\partial{x}_1}&\frac{\partial^2f}{\partial{x}_2^2}&\frac{\partial^2f}{\partial{x}_2\partial{x}_3}&\dots&\frac{\partial^2f}{\partial{x}_2\partial{x}_n}\\\\\vdots&\vdots&\vdots&\ddots&\vdots\\\\\frac{\partial^2f}{\partial{x}_n\partial{x}_1}&\frac{\partial^2f}{\partial{x}_n\partial{x}_2}&\frac{\partial^2f}{\partial{x}_n\partial{x}_3}&\dots&\frac{\partial^2f}{\partial{x}_n^2}\end{bmatrix}

Arguments

@H

Step size.

@X

The point where the Hessian is calculated.

@VarNames

The names of the variables.

@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^(-13).

Examples

Example #1

Calculate the Hessian for the function

f(x,y)=x^3-2xy-y^6

at the point (1,2) Since the result is returned as a string, we will use the MATRIX function to unpack the results into a matrix format.

SELECT *
FROM wct.MATRIX(wct.HESSIAN('SELECT POWER(@x,3) - 2*@x*@y - POWER(@y,6)',
          '@x,@y', '1,2', 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":"6"},{"RowNum":"0","ColNum":"1","ItemValue":"-2"},{"RowNum":"1","ColNum":"0","ItemValue":"-2"},{"RowNum":"1","ColNum":"1","ItemValue":"-480.000001907349"}]}

See Also

BFGS - Broyden-Fletcher-Goldfarb-Shanno (BFGS) method to find the minimum of a functionBRENT - Find the root of a continuous function of one variable

FDERIV - Numerical function differentiation for orders n = 1 to 8 using finite difference approximations

JACOBIAN - Numerically compute the Jacobian matrix

NEWTON - Find the root of a univariate function

SECANT - Find the root of single-variable continuous function.

BRENT - Find the root of a continuous function of on variable

GRAD - Numerically compute the gradient.