# API¶

class idesolver.IDESolver(x: numpy.ndarray, y_0: Union[float, complex], c: Optional[Callable] = None, d: Optional[Callable] = None, k: Optional[Callable] = None, f: Optional[Callable] = None, lower_bound: Optional[Callable] = None, upper_bound: Optional[Callable] = None, global_error_tolerance: float = 1e-06, max_iterations: Optional[int] = None, ode_method: str = 'RK45', ode_atol: float = 1e-08, ode_rtol: float = 1e-08, int_atol: float = 1e-08, int_rtol: float = 1e-08, interpolation_kind: str = 'cubic', smoothing_factor: float = 0.5, store_intermediate_y: bool = False, global_error_function: Callable = <function global_error>)[source]

A class that handles solving an integro-differential equation of the form

$\begin{split}\frac{dy}{dx} & = c(y, x) + d(x) \int_{\alpha(x)}^{\beta(x)} k(x, s) \, F( y(s) ) \, ds, \\ & x \in [a, b], \quad y(a) = y_0.\end{split}$
x

The positions where the solution is calculated (i.e., where y is evaluated).

y

The solution $$y(x)$$. None until IDESolver.solve() is finished.

global_error

The final global error estimate. None until IDESolver.solve() is finished.

Type: float
iteration

The current iteration. None until IDESolver.solve() starts.

Type: int
y_intermediate

The intermediate solutions. Only exists if store_intermediate_y is True.

Parameters: x (numpy.ndarray) – The array of $$x$$ values to find the solution $$y(x)$$ at. Generally something like numpy.linspace(a, b, num_pts). y_0 (float or complex) – The initial condition, $$y_0 = y(a)$$. c – The function $$c(y, x)$$. d – The function $$d(x)$$. k – The kernel function $$k(x, s)$$. f – The function $$F(y)$$. lower_bound – The lower bound function $$\alpha(x)$$. upper_bound – The upper bound function $$\beta(x)$$. global_error_tolerance (float) – The algorithm will continue until the global errors goes below this or uses more than max_iterations iterations. If None, the algorithm continues until hitting max_iterations. max_iterations (int) – The maximum number of iterations to use. If None, iteration will not stop unless the global_error_tolerance is satisfied. Defaults to None. ode_method (str) – The ODE solution method to use. As the method option of scipy.integrate.solve_ivp(). Defaults to 'RK45', which is good for non-stiff systems. ode_atol (float) – The absolute tolerance for the ODE solver. As the atol argument of scipy.integrate.solve_ivp(). ode_rtol (float) – The relative tolerance for the ODE solver. As the rtol argument of scipy.integrate.solve_ivp(). int_atol (float) – The absolute tolerance for the integration routine. As the epsabs argument of scipy.integrate.quad(). int_rtol (float) – The relative tolerance for the integration routine. As the epsrel argument of scipy.integrate.quad(). interpolation_kind (str) – The type of interpolation to use. As the kind argument of scipy.interpolate.interp1d. Defaults to 'cubic'. smoothing_factor (float) – The smoothing factor used to combine the current guess with the new guess at each iteration. Defaults to 0.5. store_intermediate_y (bool) – If True, the intermediate guesses for $$y(x)$$ at each iteration will be stored in the attribute y_intermediate. global_error_function – The function to use to calculate the global error. Defaults to global_error().
solve(callback: Optional[Callable] = None) → numpy.ndarray[source]

Compute the solution to the IDE.

Will emit a warning message if the global error increases on an iteration. This does not necessarily mean that the algorithm is not converging, but may indicate that it’s having problems.

Will emit a warning message if the maximum number of iterations is used without reaching the global error tolerance.

Parameters: callback – A function to call after each iteration. The function is passed the IDESolver instance, the current $$y$$ guess, and the current global error. The solution to the IDE (i.e., $$y(x)$$). numpy.ndarray
idesolver.global_error(y1: numpy.ndarray, y2: numpy.ndarray) → float[source]

The default global error function.

The estimate is the square root of the sum of squared differences between y1 and y2.

Parameters: y1 (numpy.ndarray) – A guess of the solution. y2 (numpy.ndarray) – Another guess of the solution. error – The global error estimate between y1 and y2. float
idesolver.complex_quad(integrand: Callable, lower_bound: float, upper_bound: float, **kwargs) -> (<class 'complex'>, <class 'float'>, <class 'float'>, <class 'tuple'>, <class 'tuple'>)[source]

A thin wrapper over scipy.integrate.quad() that handles splitting the real and complex parts of the integral and recombining them. Keyword arguments are passed to both of the internal quad calls.