TwoPointDifferentiation Module

A two-point estimation is to compute the slope of a nearby secant line through two points. This gives an approximations of f'(x) at x respectively to two points "x and x+h"/"x-h and x+h"(depending on the used algorithm) of the function f. Choosing a small number h, h represents a small change in x, and it can be either positive or negative.

Functions and values

Function or value Description

differentiate h f x

Full Usage: differentiate h f x

Parameters:
    h : float - window for the difference calculation
    f : float -> float - f is the function for which to calculate numerical differentiation.
    x : float - x is the point at which the difference between "x and x+h"/"x-h and x+h" is calculated.

Returns: float

Returns the approximation of f'(x) at x by calculating the two point differentiation.

h : float

window for the difference calculation

f : float -> float

f is the function for which to calculate numerical differentiation.

x : float

x is the point at which the difference between "x and x+h"/"x-h and x+h" is calculated.

Returns: float

Example

differentiateOptimalH f x

Full Usage: differentiateOptimalH f x

Parameters:
    f : float -> float
    x : float

Returns: float
f : float -> float
x : float
Returns: float

differentiateOptimalHBy hArr f x

Full Usage: differentiateOptimalHBy hArr f x

Parameters:
    hArr : float[] -
    f : float -> float - function for which numerical differentiation is calculated.
    x : float - x is the point at which numerical differentiation is calculated.

Returns: float Returns the approximation of f'(x) at x by calculating the two point differentiation.

Finds optimal h from all values given in hArr and calculates "differentiate" -function.

hArr : float[]

f : float -> float

function for which numerical differentiation is calculated.

x : float

x is the point at which numerical differentiation is calculated.

Returns: float

Returns the approximation of f'(x) at x by calculating the two point differentiation.

Example