GLpoint - iparsw/differintP GitHub Wiki
GLpoint
– Endpoint Grünwald-Letnikov Fractional Derivative
Overview
GLpoint
efficiently computes the Grünwald-Letnikov fractional derivative at the endpoint of a domain, using a fast single-pass recurrence. This method is especially useful when you only need the fractional derivative at a single point (typically the rightmost point of the discretized interval).
This implementation leverages [Numba]’s just-in-time compilation to achieve near C-level performance, even for large arrays.
Mathematical Background
The Grünwald-Letnikov (GL) derivative at the endpoint $x_N$ is given by:
$$ D^\alpha f(x_N) \approx h^{-\alpha} \sum_{j=0}^{N} (-1)^j \binom{\alpha}{j} f(x_{N-j}) $$
where:
- $h$ is the step size,
- $\binom{\alpha}{j}$ is the generalized binomial coefficient.
Instead of computing all coefficients and performing a vectorized dot product (which is inefficient for a single point), GLpoint
uses a recurrence relation to generate coefficients on-the-fly, as in fast C++ implementations.
Implementation Details
-
Input Flexibility: Accepts a callable, NumPy array, or list of function values. If a function is given, it is evaluated at
num_points
equally spaced points fromdomain_start
todomain_end
. -
Optimized Kernel: The core computation is performed in a Numba JIT-compiled loop for maximum speed.
-
Efficient for Single Points: This method is much more efficient than computing the full array if only the endpoint derivative is required.
Function Signature
GLpoint(
alpha: float,
f_name: Callable | np.ndarray | list,
domain_start: float = 0.0,
domain_end: float = 1.0,
num_points: int = 100,
) -> float
Parameters
- alpha (
float
): Order of the fractional derivative. - f_name (
Callable
,list
, ornp.ndarray
): The function or sequence to differentiate. - domain_start (
float
, optional): Start of the domain. Default is0.0
. - domain_end (
float
, optional): End of the domain. Default is1.0
. - num_points (
int
, optional): Number of discretization points. Default is100
.
Returns
- result (
float
): The Grünwald-Letnikov fractional derivative at the endpoint.
Example Usage
import numpy as np
from differintP import GLpoint
# Fractional derivative of sqrt(x) at x = 1
value = GLpoint(0.5, np.sqrt, 0., 1., 1000)
print("D^0.5 sqrt(x) at x=1:", value)
Notes
- If you require the derivative at all points in the domain, use
GL
for maximum efficiency. - The function is robust for both callable functions and precomputed arrays.
See Also
GL
– Compute the Grünwald-Letnikov derivative at all pointsGLI
– Improved accuracy with Lagrange interpolation