Login     Register

        Contact Us     Search

XLeratorDB/math Documentation

SQL Server FDERIV function

Updated: 15 April 2018

Use the scalar function FDERIV for function differentiation for orders n = 1 to 4 using finite difference approximations.

   <@Func, nvarchar(max),>
  ,<@VarName, nvarchar(4000),>
  ,<@X, float,>
  ,<@N, int,>
  ,<@H, float,>
  ,<@Meth, nvarchar(4000),>)
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
@XThe starting value for the evaluation
@NOrder of derivative, should only be between 1 and 8; for n = 0 function values will be returned
@HStep size
@Meth‘C’, ‘B’, or ‘F’ for central finite difference, backward finite difference, or forward finite difference
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.
  • If @X is NULL then @X = 0.
  • If @N is NULL then @N = 1.
  • If @H is NULL then @H = 0.
  • If @Meth is NULL then @Meth = 0.
  • If @H <= 0 then @H =
  • Available in XLeratorDB / math 2008 only
Example #1

Calculate f(x) as sin x, d(sin x)/dx, and cos x

     SIN(PI()/4) as [sin x]
        'SELECT SIN(@x)'
        ) as [d(sin x)/dx]
    ,COS(PI()/4) as [cos x]

This produces the following result.

Example #2

Calculate the 1st through 4th derivatives of sin x from -PI to PI and past the results in a Excel PivotChart.

        'SELECT SIN(@x)'
FROM wct.SeriesFloat(-PI(),PI(),.02*PI(),NULL,'L')
CROSS APPLY (VALUES (1),(2),(3),(4))n(n)

This produces the following result.

See Also

Copyright 2008-2018 Westclintech LLC         Privacy Policy        Terms of Service