archimedes.quadrature.trapezoidalΒΆ
- archimedes.quadrature.trapezoidal(
- n: int,
- periodic: bool = False,
Equally-spaced trapezoidal quadrature rule.
With
periodic=False(default), the usual composite trapezoidal rule: \(n\) nodes \(t_j = -1 + 2j/(n-1)\), \(j = 0, \ldots, n-1\), spanning the closed reference interval \([-1, 1]\), with half-weight at the two endpoints.With
periodic=True, nodes \(t_j = -1 + 2j/n\), equally spaced over the half-open period \([-1, 1)\), with a node only at \(-1\): the domain is periodic, so \(-1\) and \(+1\) denote the same point and including both would double-count it. All weights equal \(2/n\). This form is exact for \(\cos(k \pi t)\) and \(\sin(k \pi t)\) for every \(1 \leq k \leq n - 1\): for equally-spaced points over one period, \(\sum_j e^{i k \cdot 2\pi j/n} = n\) if \(k \equiv 0 \pmod n\), else \(0\), so any nonzero mode strictly below the Nyquist mode \(n\) integrates to exactly zero.- Parameters:
n (int) β Number of quadrature nodes. Must be \(\geq 2\) if
periodicisFalse(at least one interval to span), or \(\geq 1\) ifperiodicisTrue.periodic (bool, optional) β If
True, build the periodic form described above β the natural rule for a Fourier/trigonometric integrand β instead of the plain closed-interval form. DefaultFalse.
- Returns:
rule β Trapezoidal rule with
nnodes, exact for degree-1 polynomials (periodic=False) or for trigonometric polynomials of mode \(\leq n - 1\) (periodic=True).- Return type:
- Raises:
ValueError β If
nis smaller than the minimum for the chosenperiodicsetting.
Notes
Tiling this rule with
composite_quad()is meaningful only forperiodic=False: its shared endpoint nodes double up across elements exactly likegauss_lobatto()βs. The periodic formβs nodes already span the whole reference domain by construction, so tiling it is mechanically possible (the shared measure is uniform-weight) but not the intended use.