-
Notifications
You must be signed in to change notification settings - Fork 0
GLpoint
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.
The Grünwald-Letnikov (GL) derivative at the endpoint
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.
-
Input Flexibility: Accepts a callable, NumPy array, or list of function values. If a function is given, it is evaluated at
num_pointsequally spaced points fromdomain_starttodomain_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.
GLpoint(
alpha: float,
f_name: Callable | np.ndarray | list,
domain_start: float = 0.0,
domain_end: float = 1.0,
num_points: int = 100,
) -> float-
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.
-
result (
float): The Grünwald-Letnikov fractional derivative at the endpoint.
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)- If you require the derivative at all points in the domain, use
GLfor maximum efficiency. - The function is robust for both callable functions and precomputed arrays.
-
GL– Compute the Grünwald-Letnikov derivative at all points -
GLI– Improved accuracy with Lagrange interpolation