-
Notifications
You must be signed in to change notification settings - Fork 0
RLpoint
RLpoint efficiently computes the Riemann-Liouville (RL) fractional integral or derivative at the endpoint of a domain, using an optimized vectorized approach with the trapezoidal rule. This is ideal when you only require the RL operator at a single point (typically the rightmost grid point).
This method provides an 8x–60x speedup compared to naïve implementations, thanks to its fully vectorized coefficient calculations and use of NumPy’s optimized routines.
The Riemann-Liouville (RL) fractional differintegral of order
Discretizing this with the trapezoidal rule leads to a sum of the form:
where
This implementation calculates these weights efficiently for the endpoint and applies them in a single dot product.
-
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 betweendomain_startanddomain_end. - Fully Vectorized: All coefficient and sum calculations are vectorized for maximum efficiency—no Python loops are used in the core computation.
- Trapezoidal Rule: Uses the trapezoidal rule to improve the accuracy of the RL integral approximation.
RLpoint(
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 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 (evaluation point). Default is1.0. -
num_points (
int, optional): Number of discretization points. Default is100.
-
result (
float): The RL fractional integral/derivative at the endpoint.
import numpy as np
from differintP import RLpoint
# Fractional integral/derivative of sqrt(x) at x = 1
rl_value = RLpoint(0.5, np.sqrt, 0., 1., 100)
# Fractional integral/derivative of a polynomial
rl_poly = RLpoint(0.5, lambda x: x**2 - 4*x - 1, 0., 1., 100)- For the RL operator at all points, see the
RLfunction. - This function is especially efficient for large
num_pointsand high-precision needs. - Coefficient calculation is based on the discretized RL formula using the trapezoidal rule.
-
RL: Compute the RL operator at all points. -
GLpoint: Endpoint Grünwald-Letnikov derivative. -
GL: Grünwald-Letnikov derivative (all points).