Test integrands#

padaquad.integrand_dict: dict[str, tuple]#

Test integrands with known integrals, by name: t, t_squared, sine_squared, exp and damped_sine. Each value is a tuple (f, solution, error_cutoff): the integrand, a function solution(mesh_init, mesh_final) returning its exact integral, and the relative error the tests accept.

padaquad.wolf_schlegel(t, _y=None)#

Quartic potential of two coordinates, evaluated along a straight path.

The path runs from \((x, y) = (1.133, -1.486)\) at t = 0 to \((-1.166, 1.477)\) at t = 1, two points within 0.001 of local minima of the potential

\[V(x, y) = 10\,(x^4 + y^4 - 2x^2 - 4y^2 + xy + 0.2x + 0.1y).\]

The integral over t from 0 to 1 is the average of V along the path. The integrand has one output (D = 1). No exact integral is provided.

Parameters:
ttorch.Tensor

Points of the integration variable t, from 0 to 1. Shape: [N, 1].

_ytorch.Tensor or None

Unused.

Returns:
torch.Tensor

V at the path point of each t. Shape: [N, 1].

Examples

>>> import torch
>>> from padaquad.examples import wolf_schlegel
>>> from padaquad import integrate
>>> _ = torch.manual_seed(0)  # the starting mesh is random
>>> result = integrate(
...     wolf_schlegel,
...     atol=1e-9,
...     rtol=1e-9,
...     mesh_init=torch.tensor([0.0], dtype=torch.float64),
...     mesh_final=torch.tensor([1.0], dtype=torch.float64),
...     device="cpu",
...     max_batch=10_000,
... )
>>> print(round(float(result.integral), 6))
-30.658508