-
Notifications
You must be signed in to change notification settings - Fork 0
PCsolver
PCsolver numerically solves fractional initial value problems (IVPs) of the form $ D^\alpha y(x) = f(x, y(x)) $ using a predictor-corrector approach, adapted to fractional orders. The method generalizes classical Adams-Bashforth-Moulton predictor-corrector techniques to support non-integer (fractional) derivatives. The implementation supports multi-term initial conditions and is suitable for orders
This solver implements the fractional Adams-Bashforth-Moulton predictor-corrector scheme, a widely-used method for numerically integrating fractional differential equations (FDEs). For an FDE of order
the algorithm computes a discrete approximation on a uniform grid. At each step, the next value is predicted using the previous solution and then corrected by evaluating both the right-hand side at the new point and a weighted sum (with PCcoeffs) over previous values.
The PCcoeffs function generates the necessary weights for the convolution sum, generalizing the classic coefficients to fractional orders.
For further theoretical background, see:
- Deng, W. (2007). "Short memory principle and a predictor-corrector approach for fractional differential equations." J. Comput. Appl. Math.
- Baskonus, H.M., Bulut, H. (2015). "On the numerical solutions of some fractional ordinary differential equations..." De Gruyter.
-
Handles Arbitrary Fractional Orders (
$1 < \alpha$ ): Supports IVPs for any order$\alpha > 1$ , automatically handling the required number of initial values. - Supports Multi-Term Initial Conditions: Accepts a list of initial values matching the integer part of the order.
-
Flexible Right-Hand Side:
The function
$f(x, y)$ can be supplied as a lambda or function handle. -
Discrete Grid:
Solution is computed at
num_pointsequally spaced points betweendomain_startanddomain_end. -
Predictor and Corrector:
Each step first predicts and then corrects the solution, using fractional weights computed by
PCcoeffs. -
Dependency:
Relies on
scipy.special.factorialandGamma(fromscipy.special).
PCsolver(
initial_values: list[float],
alpha: float,
f_name: Callable,
domain_start: float = 0.0,
domain_end: float = 1.0,
num_points: int = 100,
) -> np.ndarray-
initial_values (
list[float]): List of initial values for the IVP. The number should be at leastceil(alpha). -
alpha (
float): The order of the fractional derivative/integral ($ \alpha > 1 $). -
f_name (
Callable): Function or lambda specifying the right side of the differential equation. Must accept two arguments:xandy. -
domain_start (
float, optional): Left endpoint of the domain. Default is0.0. -
domain_end (
float, optional): Right endpoint of the domain. Default is1.0. -
num_points (
int, optional): Number of grid points. Default is100.
-
y_correction (
np.ndarray): Array containing the solution to the fractional IVP at each point in the grid.
import numpy as np
from differintP.solvers import PCsolver
# Example: Solve D^1.5 y(x) = y - x - 1 with y(0)=1, y'(0)=1
f = lambda x, y: y - x - 1
initial_values = [1, 1]
y_approx = PCsolver(initial_values, 1.5, f)
# Compare to analytical solution for validation (if known)
x = np.linspace(0, 1, 100)
theoretical = x + 1
assert np.allclose(y_approx, theoretical)- Only supports
$\alpha > 1$ (fractional orders less than 1 are not yet implemented). - The coefficients are computed via the
PCcoeffshelper function, which generates the fractional Adams-Bashforth-Moulton weights. - For more advanced or higher-order FDE solvers, see related pages or references.