Skip to content

Collocation node helpers

Node sets for the coll_nodes parameter (callable inputs). Positions are floats in [0, 1]; these helpers build the classical families. For sampled inputs the nodes must sit on samples and are given as integers through coll_setting; see Conventions.

gauss_legendre_nodes

gauss_legendre_nodes(p)

Return the p Gauss-Legendre collocation nodes on \([0, 1]\).

These interior nodes (none at 0 or 1) give the maximal collocation order. For a VIDE the solution superconverges to order \(2p\) at the mesh points. For VIE-2 the collocation solution itself does not: at an interior breakpoint the mean of its one-sided limits (the default of VolterraSolution) gains one order for \(p = 3\) (see the Conventions page, "Values at breakpoints"). For VIE-1 (first kind) Gauss nodes, being symmetric about \(1/2\), have amplification factor \(\rho_p = (-1)^p\): odd \(p\) keeps the full order \(p\), even \(p\) costs one order (see voles.solve_vie1, Notes). radau_iia_nodes have the full order for every \(p\).

Parameters:

Name Type Description Default
p int

Number of nodes (the order of the collocation method), p >= 1.

required

Returns:

Type Description
ndarray of shape (p,)

Node positions in \((0, 1)\), sorted ascending.

Examples:

>>> import voles
>>> voles.gauss_legendre_nodes(2)
array([0.21132487, 0.78867513])
Source code in src/voles/_functional.py
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
def gauss_legendre_nodes(p: int) -> np.ndarray:
    r"""Return the ``p`` Gauss-Legendre collocation nodes on $[0, 1]$.

    These interior nodes (none at 0 or 1) give the maximal collocation order.
    For a **VIDE** the solution superconverges to order $2p$ at the mesh
    points. For **VIE-2** the collocation solution itself does not: at an
    interior breakpoint the mean of its one-sided limits (the default of
    `VolterraSolution`) gains one order for $p = 3$ (see the Conventions
    page, "Values at breakpoints"). For **VIE-1** (first kind) Gauss nodes,
    being symmetric about $1/2$, have amplification factor
    $\rho_p = (-1)^p$: odd $p$ keeps the full order $p$, even $p$ costs one
    order (see `voles.solve_vie1`, Notes). ``radau_iia_nodes`` have the full
    order for every $p$.

    Parameters
    ----------
    p : int
        Number of nodes (the order of the collocation method), ``p >= 1``.

    Returns
    -------
    ndarray of shape (p,)
        Node positions in $(0, 1)$, sorted ascending.

    Examples
    --------
    >>> import voles
    >>> voles.gauss_legendre_nodes(2)
    array([0.21132487, 0.78867513])
    """
    p = _check_node_count(p, minimum=1, name="Gauss-Legendre")
    x, _ = np.polynomial.legendre.leggauss(p)
    return np.sort(0.5 * (x + 1.0))

radau_iia_nodes

radau_iia_nodes(p)

Return the p Radau IIA collocation nodes on \([0, 1]\).

The Radau IIA nodes include the right endpoint (1.0) and exclude 0. They give mesh-point superconvergence of order \(2p - 1\): for a VIDE directly, and for VIE-2 in the left limit at each breakpoint, which is the collocation value at the last node (sol(t, at_breakpoints="left"); the default mean has order \(p\)). The right-endpoint node also makes them a common choice for stiff VIDEs. For the default (discontinuous) VIE-1 method they are the recommended family: the endpoint node makes the amplification factor \(\rho_p = 0\), giving the full order \(p\) for every \(p\) (Gauss-Legendre nodes have \(\rho_p = (-1)^p\) and lose an order for even \(p\)). They do not suit continuous=True, where \(|\rho_{p-1}| = p\) and the method diverges for \(p \ge 2\) (see voles.solve_vie1, Notes).

Parameters:

Name Type Description Default
p int

Number of nodes, p >= 1.

required

Returns:

Type Description
ndarray of shape (p,)

Node positions in \((0, 1]\) (the last is exactly 1.0), sorted ascending.

Examples:

>>> import voles
>>> voles.radau_iia_nodes(2)
array([0.33333333, 1.        ])
Source code in src/voles/_functional.py
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
def radau_iia_nodes(p: int) -> np.ndarray:
    r"""Return the ``p`` Radau IIA collocation nodes on $[0, 1]$.

    The Radau IIA nodes include the right endpoint (``1.0``) and exclude 0.
    They give mesh-point superconvergence of order $2p - 1$: for a **VIDE**
    directly, and for **VIE-2** in the left limit at each breakpoint, which
    is the collocation value at the last node
    (``sol(t, at_breakpoints="left")``; the default mean has order $p$). The
    right-endpoint node also makes them a common choice for stiff VIDEs. For
    the default (discontinuous) **VIE-1** method they are the recommended
    family: the endpoint node makes the amplification factor $\rho_p = 0$,
    giving the full order $p$ for every $p$ (Gauss-Legendre nodes have
    $\rho_p = (-1)^p$ and lose an order for even $p$). They do not suit
    ``continuous=True``, where $|\rho_{p-1}| = p$ and the method diverges for
    $p \ge 2$ (see `voles.solve_vie1`, Notes).

    Parameters
    ----------
    p : int
        Number of nodes, ``p >= 1``.

    Returns
    -------
    ndarray of shape (p,)
        Node positions in $(0, 1]$ (the last is exactly ``1.0``), sorted
        ascending.

    Examples
    --------
    >>> import voles
    >>> voles.radau_iia_nodes(2)
    array([0.33333333, 1.        ])
    """
    p = _check_node_count(p, minimum=1, name="Radau IIA")
    # On [-1, 1] the Radau IIA nodes are the roots of P_{p-1}(x) - P_p(x); one
    # of those roots is +1. Map the roots to [0, 1].
    c = np.zeros(p + 1)
    c[p - 1] += 1.0
    c[p] -= 1.0
    # legroots may return a complex-dtype array (tiny imaginary parts from the
    # companion-matrix eigensolver) on some numpy/LAPACK versions; these nodes
    # are mathematically real, so take the real part.
    x = np.polynomial.legendre.legroots(c).real
    nodes = np.sort(0.5 * (x + 1.0))
    nodes[-1] = 1.0  # pin the endpoint exactly
    return nodes

lobatto_nodes

lobatto_nodes(p)

Return the p Gauss-Lobatto collocation nodes on \([0, 1]\) (p >= 2).

The Lobatto nodes include both endpoints (0.0 and 1.0) and have local order \(2p - 2\). Because 0 is included they suit VIE-2 and VIDE but not VIE-1, which forbids a node at \(t = 0\).

Parameters:

Name Type Description Default
p int

Number of nodes, p >= 2.

required

Returns:

Type Description
ndarray of shape (p,)

Node positions in \([0, 1]\) (the first is 0.0 and the last 1.0), sorted ascending.

Examples:

>>> import voles
>>> voles.lobatto_nodes(3)
array([0. , 0.5, 1. ])
Source code in src/voles/_functional.py
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
def lobatto_nodes(p: int) -> np.ndarray:
    r"""Return the ``p`` Gauss-Lobatto collocation nodes on $[0, 1]$ (``p >= 2``).

    The Lobatto nodes include both endpoints (``0.0`` and ``1.0``) and have
    local order $2p - 2$. Because 0 is included they suit VIE-2 and VIDE but
    **not** VIE-1, which forbids a node at $t = 0$.

    Parameters
    ----------
    p : int
        Number of nodes, ``p >= 2``.

    Returns
    -------
    ndarray of shape (p,)
        Node positions in $[0, 1]$ (the first is ``0.0`` and the last ``1.0``),
        sorted ascending.

    Examples
    --------
    >>> import voles
    >>> voles.lobatto_nodes(3)
    array([0. , 0.5, 1. ])
    """
    p = _check_node_count(p, minimum=2, name="Lobatto")
    if p == 2:
        interior = np.array([])
    else:
        # The interior Lobatto nodes are the roots of P'_{p-1}.
        c = np.zeros(p)
        c[p - 1] = 1.0
        # .real: legroots may return complex dtype (see radau_iia_nodes); these
        # interior nodes are mathematically real.
        interior = np.polynomial.legendre.legroots(
            np.polynomial.legendre.legder(c)).real
    x = np.concatenate(([-1.0], interior, [1.0]))
    nodes = np.sort(0.5 * (x + 1.0))
    nodes[0] = 0.0   # pin the endpoints exactly
    nodes[-1] = 1.0
    return nodes

Compiled collocation settings

With the default quadrature="product" the solvers accept every valid coll_setting. With quadrature="collocation" they run routines compiled into the extension for a fixed list of settings (divs ≤ 4 in current builds); any other setting runs on the optional numba fallback (scalar problems only, with a PerformanceWarning) or raises NotImplementedError.