pykbe.gregory module#

pykbe.gregory.conv_integral_r(m, k)[source]#

Double-precision version of conv_integral_r_exact.

Parameters:
mint

Nonnegative

kint

Nonnegative

Returns:
R(k+1, k+1) ndarray

Equation 104 weights for fixed m, k

See also

conv_integral_r_exact

Exact version

pykbe.gregory.conv_integral_r_exact(m, k)[source]#

Equation 104 [NESSI].

\[R^{(k)}_{m;r,s} = \sum_{a,b=0}^k P^{(k)}_{ar} P^{(k)}_{bs} \int_0^m (m-x)^a x^b \, dx\]
Parameters:
mint

Nonnegative

kint

Nonnegative

Returns:
R(k+1, k+1) ndarray

Equation 104 weights for fixed m, k

pykbe.gregory.gregory_coef(k)[source]#

Gregory coefficients.

See https://en.wikipedia.org/wiki/Gregory_coefficients.

Starting from \(G_0\), the first few coefficients are: \(-\frac{1}{2}, \frac{1}{12}, -\frac{1}{24}, \frac{19}{720}, \ldots\)

\[G_k = \frac{-1}{(k+1)!} \left[ \frac{d^{k+1}}{dz^{k+1}}\frac{z}{\ln(1+z)}\right]_{z=0}\]
Parameters:
kint

(starts from zero)

Returns:
sympy.core.numbers.Rational

kth Gregory coefficient

pykbe.gregory.gregory_weights(k)[source]#

Gregory quadrature weights (double precision).

See Table 9 in [NESSI].

Parameters:
kint

Starts from 0; gives degree of polynomial approx.

Returns:
w(k+1,) ndarray

Order n Gregory quadrature weights (double precision)

pykbe.gregory.gregory_weights_exact(k)[source]#

Gregory quadrature weights (exact).

See Table 9 in [NESSI].

\[\begin{split}\mathbf{w} = \begin{bmatrix} 1 & 0 & 0 & 0 & \cdots \\ -1 & 1 & 0 & 0 & \cdots \\ 1 & -2 & 1 & 0 & \cdots \\ -1 & 3 & -3 & 1 & \cdots \\ \vdots & \vdots & \vdots & \vdots & \ddots \\ \end{bmatrix} \begin{bmatrix} G_0 \\ G_1 \\ G_2 \\ G_3 \\ \vdots \end{bmatrix} + \begin{bmatrix} 1 \\ 1 \\ 1 \\ 1 \\ \vdots \end{bmatrix}\end{split}\]
Parameters:
kint

Starts from 0; gives degree of polynomial approx.

Returns:
w(k+1,) ndarray

Order k Gregory quadrature weights, exact.

pykbe.gregory.integral_intermediate1(m, a, b)[source]#

Evaluates \(\int_0^m (m-x)^a x^b \, dx\).

Parameters:
mint

Nonnegative.

aint

Nonnegative.

bint

Nonnegative.

Returns:
sympy.core.numbers.Rational

\(\int_0^m (m-x)^a x^b \, dx\).

See also

integral_intermediate2

Evaluates integral_intermediate1 for all a, b.

pykbe.gregory.integral_intermediate2(m, k)[source]#

Evaluates \(\int_0^m (m-x)^a x^b \, dx\) for all a, b.

\[M^{(k)}_{m; a, b} = \int_0^m (m-x)^a x^b \, dx\]
Parameters:
mint

Nonnegative.

kint

Nonnegative.

Returns:
(k+1,k+1) ndarray

See also

integral_intermediate1

to calculate a single element.

pykbe.gregory.master_gregory_weights(k, n)[source]#

Quadrature weights.

Gives row n of the matrix in Eq. 98 from [NESSI].

Parameters:
kint

Polynomial degree.

nint

Row (or upper limit of integration).

Returns:
w(n+1,) ndarray

Quadrature weights.

pykbe.gregory.poly_backdifferentiation_weights(n, rev=True)[source]#
pykbe.gregory.poly_backdifferentiation_weights_exact(n)[source]#
pykbe.gregory.poly_differentiation_weights(k)[source]#

Double precision polynomial differentiation weights.

Same as poly_differentiation_weights_exact but in double precision.

Parameters:
kint

Polynomial degree.

Returns:
D(k+1,k+1) ndarray

Polynomial differentiation weights.

pykbe.gregory.poly_differentiation_weights_exact(k)[source]#

Polynomial differentiation weights.

See equation 85 in [NESSI].

\[D^{(k)}_{ml} = \sum_{a=1}^k P^{(k)}_{al}a m^{a-1}.\]
Parameters:
kint

Polynomial degree.

Returns:
D(k+1,k+1) ndarray

Polynomial differentiation weights.

pykbe.gregory.poly_integration_weights(k)[source]#

Double precision polynomial integration weights.

Same as poly_integration_weights_exact but in double precision.

Parameters:
kint

Polynomial degree.

Returns:
I(k+1,k+1) ndarray

Polynomial integration weights.

pykbe.gregory.poly_integration_weights_exact(k)[source]#

Polynomial integration weights.

\[\begin{split}I^{(k)} = \begin{bmatrix} 0 & 0 & 0 & \cdots & 0 \\ \frac{1}{1} & \frac{1}{2} & \frac{1}{3} & \cdots & \frac{1}{k+1} \\ \frac{2^1}{1} & \frac{2^2}{2} & \frac{2^3}{3} & \cdots & \frac{2^{k+1}}{k+1} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ \frac{k^1}{1} & \frac{k^2}{2} & \frac{k^3}{3} & \cdots & \frac{k^{k+1}}{k+1} \\ \end{bmatrix} (V^{(k)})^{-1}\end{split}\]
Parameters:
kint

Polynomial degree.

Returns:
I(k+1,k+1) ndarray

Polynomial integration weights.

pykbe.gregory.poly_interpolation_weights(k)[source]#

Double precision polynomial interpolation weights.

Same as poly_interpolation_weights_exact but in double precision.

Parameters:
kint

Polynomial degree.

Returns:
P(k+1,k+1) ndarray
pykbe.gregory.poly_interpolation_weights_exact(k)[source]#

Polynomial interpolation weights (exact).

\[P^{(k)} = (V^{(k)})^{-1}\]
Parameters:
kint

Polynomial degree.

Returns:
P(k+1,k+1) ndarray
pykbe.gregory.sigma_weights(k)[source]#

Sigma quadrature weights.

Parameters:
kint

Starts from 0; gives degree of polynomial approx.

Returns:
sigma(k+1, 2k+2) ndarray

Order k sigma quadrature weights, double precision.

pykbe.gregory.sigma_weights_exact(k)[source]#

Sigma quadrature weights (exact).

Parameters:
kint

Starts from 0; gives degree of polynomial approx.

Returns:
sigma(k+1, 2k+2) ndarray

Order k sigma quadrature weights, exact.

pykbe.gregory.sympy_inv_vandermonde(k)[source]#

Inverse of Vandermonde matrix.

Parameters:
kint

Polynomial degree.

Returns:
vinv(k+1, k+1) sympy.matrices.dense.DenseMatrix

Inverse of Vandermonde matrix constructed from points 0, 1, …, n

pykbe.gregory.sympy_vandermonde(k)[source]#

Vandermonde matrix.

\[\begin{split}V^{(k)} = \begin{bmatrix} 1 & 0 & 0 & \cdots & 0 \\ 1 & 1 & 1 & \cdots & 1 \\ 1 & 2^1 & 2^2 & \cdots & 2^n \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1 & k & k^2 & \cdots & k^k \\ \end{bmatrix}\end{split}\]
Parameters:
kint

Polynomial degree.

Returns:
v(k+1, k+1) sympy.matrices.dense.DenseMatrix

Vandermonde matrix constructed from points 0, 1, …, k

References#

[NESSI] (1,2,3,4,5)

Schüler, M.; Golež, D.; Murakami, Y.; Bittner, N.; Herrmann, A.; Strand, H. U. R.; Werner, P.; Eckstein, M. NESSi: The Non-Equilibrium Systems Simulation Package. Computer Physics Communications, 2020, 257, 107484. https://doi.org/10.1016/j.cpc.2020.107484.