FunctionMath.Derivative Method

Definition

Namespace: Extreme.Mathematics
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23

Overload List

Derivative(Func<Double, Double>, Double) Returns an approximation to the derivative of a function.
Derivative(Func<Double, Double>, Double, DifferencesDirection) Returns an approximation to the derivative of a function.
Derivative(Func<Double, Double>, Double, Double) Returns an approximation to the derivative of a function.
Derivative(Func<Double, Double>, Double, DifferencesDirection, Int32) Returns an approximation to the derivative of a function.

Derivative(Func<Double, Double>, Double)

Returns an approximation to the derivative of a function.
C#
public static double Derivative(
	this Func<double, double> targetFunction,
	double x
)

Parameters

targetFunction  Func<Double, Double>
A delegate that represents a function of one variable that specifies the function to differentiate.
x  Double
The point at which to evaluate the derivative.

Return Value

Double
A numerical approximation to the derivative of targetFunction at x.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Func<Double, Double>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

ArgumentNullExceptiontargetFunction is null.

Derivative(Func<Double, Double>, Double, DifferencesDirection)

Returns an approximation to the derivative of a function.
C#
public static double Derivative(
	this Func<double, double> targetFunction,
	double x,
	DifferencesDirection direction
)

Parameters

targetFunction  Func<Double, Double>
A delegate that represents a function of one variable that specifies the function to differentiate.
x  Double
The point at which to evaluate the derivative.
direction  DifferencesDirection
A DifferencesDirection that specifies the interval to be used for differentiation.

Return Value

Double
A numerical approximation to the derivative of targetFunction at x.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Func<Double, Double>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

This method is useful when the targetFunction is not defined or is discontinuous on either side of x.

If the function is badly behaved on the left, you can set direction to Forward, and the function will only be evaluated at x and to the right of x. Passing Forward causes the function to be evaluated at x and points to the left of x.

If the function is well-behaved on both sides, you should use Central, since that will, in general, yield better results. This is also the default when the direction parameter is omitted.

Exceptions

ArgumentNullExceptiontargetFunction is null.

Derivative(Func<Double, Double>, Double, Double)

Returns an approximation to the derivative of a function.
C#
public static double Derivative(
	this Func<double, double> targetFunction,
	double x,
	out double error
)

Parameters

targetFunction  Func<Double, Double>
A delegate that represents a function of one variable that specifies the function to differentiate.
x  Double
The point at which to evaluate the derivative.
error  Double
On return, an estimate for the error in the derivative.

Return Value

Double
A numerical approximation to the derivative of targetFunction at x.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Func<Double, Double>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

ArgumentNullExceptiontargetFunction is null.

Derivative(Func<Double, Double>, Double, DifferencesDirection, Int32)

Returns an approximation to the derivative of a function.
C#
public static double Derivative(
	this Func<double, double> targetFunction,
	double x,
	DifferencesDirection direction,
	out int evaluationsNeeded
)

Parameters

targetFunction  Func<Double, Double>
A delegate that represents a function of one variable that specifies the function to differentiate.
x  Double
The point at which to evaluate the derivative.
direction  DifferencesDirection
A DifferencesDirection that specifies the interval to be used for differentiation.
evaluationsNeeded  Int32
On exit, contains the number of function evaluations needed to evaluate the derivative.

Return Value

Double
A numerical approximation to the derivative of targetFunction at x.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Func<Double, Double>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

This method is useful when the targetFunction is not defined or is discontinuous on either side of x.

If the function is badly behaved on the left, you can set direction to Forward, and the function will only be evaluated at x and to the right of x. Passing Forward causes the function to be evaluated at x and points to the left of x.

If the function is well-behaved on both sides, you should use Central, since that will, in general, yield better results. This is also the default when the direction parameter is omitted.

Exceptions

ArgumentNullExceptiontargetFunction is null.

See Also