grid.onedgrid module#

1D integration grid.

class grid.onedgrid.ClenshawCurtis(npoints: int)#

Bases: OneDGrid

Clenshaw-Curtis integral quadrature class.

The definition of this quadrature is:

\[\begin{split}\theta_i &= \pi (i - 1) / (n - 1) \\ x_i &= \cos (\theta_i) \\ w_i &= \frac{c_k}{n} \bigg(1 - \sum_{j=1}^{\lfloor n/2 \rfloor} \frac{b_j}{4j^2 - 1} \cos(2j\theta_i) \bigg) \\ b_j &= \begin{cases} 1 & \text{if } j = n/2 \\ 2 & \text{if } j < n/2 \end{cases} \\ c_j &= \begin{cases} 1 & \text{if } k = 0, n\\ 2 & else \end{cases}\end{split}\]

where \(k=0,\cdots ,n\).

If discontinuous, it is recommended to break the intervals at the discontinuities and handled separately.

name = 'Clenshaw-Curtis'#
class grid.onedgrid.ExpExp(npoints: int, h: float = 0.1)#

Bases: OneDGrid

Exponential-Exponential quadrature class.

The definition of this quadrature is:

\[\begin{split}\int_{0}^{\infty} f(x) dx \approx \sum_{k=-n}^n w_k f(x_k). \\ x_k = e^{kh} e^{-e^{-kh}} \\ w_k = h e^{-e^{-kh}}\left( e^{kh} + 1 \right)\end{split}\]

Warnings#

  • Using this quadrature requires heavy parameter-tuning in-order to work.

name = 'Exponential-Exponential'#
class grid.onedgrid.ExpSinh(npoints: int, h: float = 1.0)#

Bases: OneDGrid

Exponential-Hyperbolic Sine quadrature class.

The definition of this quadrature is:

\[\begin{split}\int_{0}^{\infty} f(x) dx \approx \sum_{k=-n}^n w_k f(x_k). \\ x_k = \exp \left(\frac{\pi}{2}\sinh(k h) \right) \\ w_k = \exp \left(\frac{\pi}{2}\sinh(k h) \right)\left(\frac{\pi h}{2} \cosh(k h) \right)\end{split}\]

Warnings#

  • Using this quadrature requires heavy parameter-tuning in-order to work.

name = 'Exponential-Hyperbolic-Sine'#
class grid.onedgrid.FejerFirst(npoints: int)#

Bases: OneDGrid

Fejer first integral quadrature class.

The definition of this quadrature is:

\[\begin{split}\theta_i &= \frac{(2i - 1)\pi}{2n}, \\ x_i &= \cos(\theta_i), \\ w_i &= \frac{2}{n}\bigg(1 - 2 \sum_{j=1}^{\lfloor n/2 \rfloor} \frac{\cos(2j \theta_j)}{4 j^2 - 1} \bigg),\end{split}\]

where \(k=1,\cdots, n\). It uses the zeros of the Chebyshev polynomial. If discontinuous, it is recommended to break the intervals at the discontinuities and handled separately.

name = 'Fejer-First'#
class grid.onedgrid.FejerSecond(npoints: int)#

Bases: OneDGrid

Fejer Second integral quadrature class.

The definition of this quadrature is:

\[\begin{split}\theta_i &= k \pi / n \\ x_i &= \cos(\theta_i) \\ w_i &= \frac{4 \sin(\theta_i)}{n} \sum_{j=1}^{\lfloor n/2 \rfloor} \frac{\sin(2j - 1)\theta_i}{2j - 1}\\\end{split}\]

where \(k=1, \cdots n - 1\) and \(n\) is the number of points. This method is considered more practical than the first method. If discontinuous, it is recommended to break the intervals at the discontinuities and handled separately.

name = 'Fejer-Second'#
class grid.onedgrid.GaussChebyshev(npoints: int)#

Bases: OneDGrid

Gauss-Chebyshev integral quadrature class.

The fundamental definition of Gauss-Chebyshev quadrature is:

\[\begin{split}\int_{-1}^{1} \frac{f(x)}{\sqrt{1-x^2}} dx \approx& \sum_{i=1}^n w_i f(x_i) \\ x_i =& \cos\left( \frac{2i-1}{2n}\pi \right) \\ w_i =& \frac{\pi}{n}\end{split}\]

However, to integrate a given function \(g(x)\) over \([-1, 1]\), this is re-written as:

\[\int_{-1}^{1}g(x)dx \approx \sum_{i=1}^n \left(w_i\sqrt{1-x_i^2}\right)g(x_i) = \sum_{i=1}^n w_i'g(x_i)\]
name = 'Gauss-Chebyshev'#
class grid.onedgrid.GaussChebyshevLobatto(npoints: int)#

Bases: OneDGrid

Gauss Chebyshev Lobatto integral quadrature class.

The definition of Gauss-Chebyshev-Lobato quadrature is:

\[\begin{split}\int_{-1}^{1} \frac{f(x)}{\sqrt{1-x^2}} dx \approx& \sum_{i=1}^n w_i f(x_i) \\ x_i =& \cos\left( \frac{(i-1)}{n-1}\pi \right) \\ w_{1} = w_{n} =& \frac{\pi}{2(n-1)} \\ w_{i\neq 1,n} =& \frac{\pi}{n-1}\end{split}\]

However, to integrate a given function \(g(x)\) over \([-1, 1]\), this is re-written as:

\[\int_{-1}^{1}g(x) dx \approx \sum_{i=1}^n \left(w_i \sqrt{1-x_i^2}\right) g(x_i) = \sum_{i=1}^n w_i' g(x_i)\]
name = 'Gauss-Chebyshev-Lobatto'#
class grid.onedgrid.GaussChebyshevType2(npoints: int)#

Bases: OneDGrid

Gauss Chebyshev Type2 integral quadrature class.

The definition of the Gauss-Chebyshev of the second kind quadrature is:

\[\begin{split}\int_{-1}^{1} f(x) \sqrt{1-x^2} dx \approx& \sum_{i=1}^n w_i f(x_i) \\ x_i =& \cos\left( \frac{i}{n+1} \pi \right) \\ w_i =& \frac{\pi}{n+1} \sin^2 \left( \frac{i}{n+1} \pi \right)\end{split}\]

However, to integrate a given function \(g(x)\) over \([-1, 1]\), this is re-written as:

\[\int_{-1}^{1} g(x) dx \approx \sum_{i=1}^n \left(\frac{w_i}{\sqrt{1-x_i^2}}\right) g(x_i) = \sum_{i=1}^n w_i' g(x_i)\]
name = 'Gauss-Chebyshev-Type2'#
class grid.onedgrid.GaussLaguerre(npoints: int, alpha: float = 0)#

Bases: OneDGrid

Gauss Laguerre integral quadrature class.

The definition of generalized Gauss-Laguerre quadrature is:

\[\int_{0}^{\infty} x^\alpha e^{-x} f(x) dx \approx \sum_{i=1}^n w_i f(x_i),\]

where \(\alpha > -1\).

However, to integrate function \(g(x)\) over \([0, \infty)\), this is re-written as:

\[\int_{0}^{\infty} g(x)dx \approx \sum_{i=1}^n \left(\frac{w_i}{x_i^\alpha e^{-x_i}}\right) g(x_i) = \sum_{i=1}^n w_i' g(x_i)\]
name = 'Gauss-Laguerre'#
class grid.onedgrid.GaussLegendre(npoints: int)#

Bases: OneDGrid

Gauss-Legendre integral quadrature class.

The definition of Gauss-Legendre quadrature is:

\[\int_{-1}^{1} f(x) dx \approx \sum_{i=1}^n w_i f(x_i),\]

where \(w_i\) are the quadrature weights and \(x_i\) are the roots of the nth Legendre polynomial.

name = 'Gauss-Legendre'#
class grid.onedgrid.LogExpSinh(npoints: int, h: float = 0.1)#

Bases: OneDGrid

Logarithm-Exponential-Hyperbolic Sine quadrature class.

The definition of this quadrature is:

\[\begin{split}\int_{0}^{\infty} f(x) dx \approx \sum_{k=-n}^n w_k f(x_k). \\ x_k = \log \left( \exp \left(\frac{\pi}{2}\sinh(kh) \right) + 1\right) \\ w_k = \frac{\pi h\cosh(kh)\exp(\frac{\pi}{2}\sinh(kh))} {2(\exp(\frac{\pi}{2}\sinh(kh))+1)}.\end{split}\]

Warnings#

  • Using this quadrature requires heavy parameter-tuning in-order to work.

name = 'Logarithm-Exponential-Hyperbolic-Sine'#
class grid.onedgrid.MidPoint(npoints: int)#

Bases: OneDGrid

MidPoint integral quadrature class.

The definition of this quadrature is:

\[\begin{split}\int_{-1}^{1} f(x) dx \approx& \sum_{i=1}^n w_i f(x_i) \\ x_i =& -1 + \frac{2i + 1}{n} \\ w_i =& \frac{2}{n}\end{split}\]
name = 'MidPoint'#
class grid.onedgrid.RectangleRuleSineEndPoints(npoints: int)#

Bases: OneDGrid

Rectangle-Rule Sine end points integral quadrature class. [1]

\[\begin{split}\int_{-1}^{1} f(x) dx \approx& \sum_{i=1}^n w_i f(x_i) \\ x_i =& \frac{i}{n+1} \\ w_i =& \frac{2}{n+1} \sum_{m=1}^n \frac{\sin(m \pi x_i)(1-\cos(m \pi))}{m \pi}\end{split}\]

For consistency with other 1-D grids, the integration range is modified by \(q=2x-1\) to the interval \([-1, 1]\), so that

\[2 \int_{0}^{1} f(x) dx = \int_{-1}^{1} f(q) dq\]

References#

name = 'Rectangle-Rule-Sine'#
class grid.onedgrid.Simpson(npoints: int)#

Bases: OneDGrid

Simpson integral quadrature class.

The definition of this quadrature is:

\[\int_{-1}^{1} f(x) dx \approx \sum_{i=1}^n w_i f(x_i),\]

where

\[\begin{split}x_i &= -1 + 2 \left(\frac{i-1}{n-1}\right), w_i &= \begin{cases} 2 / (3(N - 1)) & i = 0 \\ 8 / (3(N - 1)) & i \geq 1 \text{and is odd}, \\ 4 / (3(N - 1)) & i \geq 2 \text{and is even}. \end{cases}\end{split}\]
name = 'Simpson'#
class grid.onedgrid.SingleArcSinhExp(npoints: int, h: float = 0.1)#

Bases: OneDGrid

Single Arc Hyperbolic Sine-Exponential quadrature class.

The definition of this quadrature is:

\[\begin{split}\int_{0}^{\infty} f(x) dx \approx \sum_{k=-n}^n w_k f(x_k). \\ x_k = \mbox{arcsinh}(e^{kh}) \\ w_k = \frac{h e^{kh}}{\sqrt{e^{2kh} + 1}}\end{split}\]

Warnings#

  • Using this quadrature requires heavy parameter-tuning in-order to work.

name = 'Single-Arc-Hyperbolic-Sine-Exponential'#
class grid.onedgrid.SingleExp(npoints: int, h: float = 0.1)#

Bases: OneDGrid

Single exponential quadrature class.

The definition of this quadrature is:

\[\begin{split}\int_{0}^{\infty} f(x) dx \approx \sum_{k=-n}^n w_k f(x_k). \\ x_k = e^{kh} \\ w_k = h e^{kh}.\end{split}\]

Warnings#

  • Using this quadrature requires heavy parameter-tuning in-order to work.

name = 'Single-Exponential'#
class grid.onedgrid.SingleTanh(npoints: int, h: float = 0.1)#

Bases: OneDGrid

Hyperbolic Tan quadrature class.

The definition of this quadrature is:

\[\begin{split}\int_{-1}^{1} f(x) dx \approx \sum_{k=-n}^n w_k f(x_k). \\ x_k = \tanh{kh} \\ w_k = \frac{h}{\cosh^2(kh)}\end{split}\]
name = 'Hyperbolic-Tan'#
class grid.onedgrid.TanhSinh(npoints: int, delta: float = 0.1)#

Bases: OneDGrid

Tanh Sinh integral quadrature class.

The definition of the quadrature is:

\[\begin{split}\int_{-1}^{1} f(x) dx \approx& \sum_{i=-\frac{1}{2}(n-1)}^{\frac{1}{2}(n-1)} w_i f(x_i) \\ x_i =& \tanh\left( \frac{\pi}{2} \sinh(i\delta) \right) \\ w_i =& \frac{\frac{\pi}{2}\delta \cosh(i\delta)}{\cosh^2(\frac{\pi}{2}\sinh(i\delta))}\end{split}\]

This quadrature is useful when singularities or infinite derivatives exist on the endpoints of \([-1, 1]\).

name = 'Tanh-Sinh'#
class grid.onedgrid.Trapezoidal(npoints: int)#

Bases: OneDGrid

Trapezoidal Lobatto integral quadrature class.

The fundamental definition of Trapezoidal rule is:

\[\begin{split}\int_{-1}^{1} f(x) dx \approx& \sum_{i=1}^n w_i f(x_i) \\ x_i =& -1 + 2 \left(\frac{i-1}{n-1}\right) \\ w_1 = w_n =& \frac{1}{n} \\ w_{i\neq 1,n} =& \frac{2}{n}\end{split}\]
name = 'Trapezoidal-Lobatto'#
class grid.onedgrid.TrefethenCC(npoints: int, d: int = 9)#

Bases: OneDGrid

Trefethen polynomial transformation of Clenshaw-Curtis integral quadrature class [2].

References#

name = 'Trefethen-Polynomial-Transformation-Clenshaw-Curtis'#
class grid.onedgrid.TrefethenGC2(npoints: int, d: int = 9)#

Bases: OneDGrid

Trefethen polynomial transformation of Gauss-Chebyshev of the second kind quadrature [3].

References#

name = 'Trefethen-Polynomial-Transformation-Gauss-Chebyshev-Type2'#
class grid.onedgrid.TrefethenGeneral(npoints: int, quadrature: OneDGrid, d=9)#

Bases: OneDGrid

Trefethen polynomial transformation of a general integral quadrature class [4].

References#

name = 'Trefethen-Polynomial'#
class grid.onedgrid.TrefethenStripCC(npoints: int, rho: float = 1.1)#

Bases: OneDGrid

Trefethen strip transformation of Clenshaw-Curtis quadrature [5].

References#

name = 'Trefethen-Strip-Transformation-Clenshaw-Curtis'#
class grid.onedgrid.TrefethenStripGC2(npoints: int, rho: float = 1.1)#

Bases: OneDGrid

Trefethen strip transformation of the Gauss-Chebyshev of the second kind quadrature [6].

References#

name = 'Trefethen-Strip-Transformation-Gauss-Chebyshev-Type2'#
class grid.onedgrid.TrefethenStripGeneral(npoints: int, quadrature, rho: float = 1.1)#

Bases: OneDGrid

Trefethen Strip General integral quadrature class [7].

References#

name = 'Trefethen-Strip-General'#
class grid.onedgrid.UniformInteger(npoints: int)#

Bases: OneDGrid

HORTON2 integral quadrature (HortonLinear) class.

\[\begin{split}\int_{0}^{n} f(x) dx \approx& \sum_{i=1}^n w_i f(x_i) \\ x_i =& i - 1 \\ w_i =& 1.0\end{split}\]
name = 'Uniform-Integer'#