Numerical Differentiation
This module provides approximation methods for calculating the derivatives of functions numerically.
Central_diff_first_deri(x, h, func)
Function to calculate the first derivative via Central differences.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Point were the derivative needs to be calculated |
required |
h
|
float
|
Stepsize |
required |
func
|
function
|
Function that needed to be evaluated |
required |
Return
value (float): Value of the derivative
Source code in openum/numdiff.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
Richardson(x, h, func)
Function to calculate the derivative via Richardson extrapolation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Point were the derivative needs to be calculated |
required |
h
|
float
|
Stepsize |
required |
func
|
function
|
Function that needed to be evaluated |
required |
Return
value (float): Value of the derivative
Source code in openum/numdiff.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
spline_derivative(i, x_val, x, func)
Computes the first derivative of a function using cubic spline interpolation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i
|
int
|
Index of the left boundary of the interval [x[i], x[i+1]]. |
required |
x_val
|
float
|
The point at which to evaluate the derivative. |
required |
x
|
ndarray
|
Array of grid points. |
required |
func
|
Callable
|
The function to be interpolated. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
Optional[float]
|
The derivative of the spline at x_val, or None if evaluation fails. |
Source code in openum/numdiff.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |