numericalderivative.FiniteDifferenceFormula

class numericalderivative.FiniteDifferenceFormula(function, x, args=None)

Compute a derivative of the function using finite difference formula

Methods

get_function()

Return the function

get_x()

Return the input point

__init__(function, x, args=None)

Compute a derivative of the function using finite difference formula

This class can only be used trough its children classes.

Parameters:
functionfunction

The function to differentiate.

xfloat

The point where the derivative is to be evaluated.

argslist

A list of optional arguments that the function takes as inputs. By default, there is no extra argument and calling sequence of the function must be y = function(x). If there are extra arguments, then the calling sequence of the function must be y = function(x, arg1, arg2, ...) where arg1, arg2, ..., are the items in the args list.

Returns:
None.

Examples

>>> import numericalderivative as nd
>>> import numpy as np
>>>
>>> def scaled_exp(x):
>>>     alpha = 1.e6
>>>     return np.exp(-x / alpha)
>>>
>>> x = 1.0
>>> formula = nd.FirstDerivativeForward(scaled_exp, x)
>>> function = formula.get_function()
>>> x = formula.get_x()

Methods

__init__(function, x[, args])

Compute a derivative of the function using finite difference formula

get_function()

Return the function

get_x()

Return the input point

get_function()

Return the function

Returns:
functionfunction

The function

get_x()

Return the input point

Returns:
xlist

The point