Overview
The derivative is instantaneous slope of a function at a given point, calculated using the methods of calculus.
Taylors Formula
{% f(x_{i+1}) = f(x_i) + f'(x_i)h + \frac{f''(x_i)}{2} h^2 + ... %}
{% f'(x_i) = \frac{f(x_{i+1}) - f(x_i)}{h}
- \frac{f(x_{i+2}) -2 f(x_{i+1}) + f(x_i)}{2h^2}
+ ...
%}
Taking just the first term we get
{% f'(x_i) \approx \frac{f(x_{i+1}) - f(x_i)}{h}
%}
If we take the first two terms, we get a more accurate formula
{% f'(x_i) = \frac{-f(x_{i+2}) + 4f(x_{i+1}) - 3f(x_i)}{2h} %}
The three point method is implemented in
differentiation library.
Forward and Backward Differences
Forward Difference
{% f'(x) \approx \frac{f(x+h) - f(x)}{h}
%}
Backward Difference
{% f'(x) \approx \frac{f(x) - f(x-h)}{h}
%}
Mid point Difference
{% f'(x) \approx \frac{f(x+0.5 \times h) - f(x-0.5 \times h)}{h}
%}
All methods are implemented in the
differentiation library.
Second Derivative
{% f''(x_i) = \frac{f(x_{i+2}) -2 f(x_{i+1}) + f(x_i)}{h^2} %}