-
Notifications
You must be signed in to change notification settings - Fork 0
RL computes the Riemann-Liouville (RL) fractional integral or derivative of a function at all points in a specified domain, using an optimized vectorized approach with the trapezoidal rule. This makes it possible to evaluate the RL operator efficiently on large arrays, providing up to a 14x speedup over naïve implementations.
The Riemann-Liouville (RL) fractional differintegral of order
Discretizing this integral on a uniform grid using the trapezoidal rule yields:
where
-
Input Flexibility: Accepts a callable, NumPy array, or list of function values. If a function is provided, it is evaluated at
num_pointsequally spaced points betweendomain_startanddomain_end. -
Fully Vectorized: All computations are vectorized, leveraging NumPy’s fast matrix operations.
-
Trapezoidal Rule: The RL operator is discretized using the trapezoidal rule for improved accuracy compared to simple Riemann sums.
-
Optimized RL Matrix: The RL weights are precomputed in a matrix (
RLmatrix), and the operation is performed via fast matrix multiplication.
RL(
alpha: float,
f_name: Callable | np.ndarray | list,
domain_start: float = 0.0,
domain_end: float = 1.0,
num_points: int = 100,
) -> np.ndarray-
alpha (
float): Order of the fractional differintegral to compute. -
f_name (
Callable,list, ornp.ndarray): The function or sequence to be differintegrated. -
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 (
np.ndarray): Array containing the RL fractional integral/derivative at each grid point.
import numpy as np
from differintP import RL
# Fractional integral/derivative of sqrt(x) at all points in [0, 1]
RL_sqrt = RL(0.5, np.sqrt, 0., 1., 100)
# Fractional integral/derivative of a polynomial
RL_poly = RL(0.5, lambda x: x**2 - 1, 0., 1., 100)- For the RL operator at a single endpoint, see
RLpoint. - The underlying RL matrix (
RLmatrix) is fully vectorized for high performance. - Suitable for large arrays and high-precision computations.
-
RLpoint: RL operator at the endpoint. -
GL: Grünwald-Letnikov derivative (all points). -
GLpoint: GL endpoint derivative.
- Oldham, K. & Spanier, J. (1974). The Fractional Calculus: Theory and Applications of Differentiation and Integration to Arbitrary Order. Academic Press.