Login     Register

        Contact Us     Search

XLeratorDB/math Documentation

SQL Server BRENT function

Updated: 17 April 2018

Use the scalar function BRENT to find the root of a continuous function of one variable.

SELECT [wct].[BRENT] (
   <@Func, nvarchar(max),>
  ,<@VarName, nvarchar(4000),>
  ,<@A, float,>
  ,<@B, float,>
  ,<@MaxIter, int,>
  ,<@tol, float,>)
Input NameDescription
@FuncThe function to be evaluated, as a string. The function must be in the form of a SELECT statement.
@VarNameThe name of the variable
@AOne of the 2 starting values
@BAnother starting value
@MaxIterMaximum number of iterations
@tolAbsolute tolerance
Return Type
  • 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.
  • The solution must be bound by @A and @B.
  • If @A is NULL then @A = 0
  • If @B is NULL then @B = 0
  • If @MaxIter is NULL then @MaxIter = 100
  • If @tol is NULL then @tol = 0.
  • If @tol <= 0 then @tol = 0.0000000149011612
  • Available in XLeratorDB / math 2008 only
Example #1

Let’s find the rout of the Legendre polynomial of degree 5.

         'SELECT (63 * POWER(@x,5) - 70 * POWER(@x,3) + 15 * @x)/8e+00'
        ) as brent

This produces the following result.

Example #2

In this example we call the XLeratorDB PRICE function to calculate the yield on a bond using the BRENT function and compare that with value returned by the XLeratorDB YIELD function.

        'SELECT wct.PRICE(
            ,0) - 98.25'
        ) as brent
        ,0) as yield

This produces the following result.

See Also

Copyright 2008-2023 Westclintech LLC         Privacy Policy        Terms of Service