Source code for py_core.py_numerics_core.calculus.derivative

[docs] def d_c(f,x0,h): """Computes central difference derivative estimate of a given function Args: f (function): function to differentiate x0 (float): differentiantion point h (float): epsilon size Returns: float: derivative estimate """ return (f(x0+h) - f(x0-h))/(2*h)
[docs] def d_f(f,x0,h): """Computes forward difference derivative estimate of a given function Args: f (function): function to differentiate x0 (float): differentiantion point h (float): epsilon size Returns: float: derivative estimate """ return (f(x0+h) - f(x0))/h
[docs] def d_b(f,x0,h): """Computes backward difference derivative estimate of a given function Args: f (function): function to differentiate x0 (float): differentiantion point h (float): epsilon size Returns: float: derivative estimate """ return (f(x0) - f(x0-h))/h
[docs] def d_fp(f,x0,h): """Computes five point difference derivative estimate of a given function Args: f (function): function to differentiate x0 (float): differentiantion point h (float): epsilon size Returns: float: derivative estimate """ return (f(x0-2*h) - 8*f(x0-h) + 8*f(x0+h) - f(x0+2*h))/(12*h)