|
| Union[float, NDArray[np.float64]] | gaussian (Union[float, NDArray[np.float64]] y, float sigma) |
| |
| Union[float, NDArray[np.float64]] | power_law (Union[float, NDArray[np.float64]] k, float nu) |
| |
| NDArray[np.float64] | finite_differences_coefficients (int num_points, int derivative_order=1) |
| |
| float | finite_differences (Callable[[float], float] func, float x_val, int order=1, int grid_points=3, float step_size=1e-5) |
| |
| float | binomial (int a, int b) |
| |
| int | hermite_number (int n) |
| |
| float | gaussian_derivative (float y, float sigma, int order) |
| |
| float | lattice_contribution (float x_val, float nu, float sigma, int order) |
| |
| float | sum_func (float x_val, float nu, float sigma) |
| |
| float | integral (float x_val, float nu, float sigma) |
| |
| float | sem (float x_val, float nu, float sigma, int order) |
| |
| Union[float, NDArray[np.float64]] | min_abs_rel_error (Union[float, NDArray[np.float64]] ref, Union[float, NDArray[np.float64]] approx) |
| |
| None | plot_left (Axes ax, NDArray[np.float64] x_values, dict[str, NDArray[np.float64]] plot_data_values, float nu) |
| |
| None | plot_right (Axes ax, NDArray[np.float64] x_values, NDArray[np.float64] diff1, Union[NDArray[np.float64], None] diff2) |
| |
|
|
int | EPS_TAYLOR = 1e-8 |
| |
|
int | EPS_IS_CLOSE = 1e-12 |
| |
| | parser |
| |
|
| type |
| |
|
| default |
| |
|
| help |
| |
|
| args = parser.parse_args() |
| |
|
| NU0 = args.nu |
| |
|
int | SIGMA0 = 100 |
| |
|
| x = np.linspace(-2 * SIGMA0, 2 * SIGMA0, 51) |
| |
|
| ax1 |
| |
|
| ax2 |
| |
|
| figsize |
| |
|
| integral_values = np.array([integral(xx, NU0, SIGMA0) for xx in x]) |
| |
|
| sum_func_values = np.array([sum_func(xx, NU0, SIGMA0) for xx in x]) |
| |
|
| sem_order_0_values = np.array([sem(xx, NU0, SIGMA0, 0) for xx in x]) |
| |
| | diff_order_0 |
| |
|
Union | diff_order_2 = None |
| |
|
| sem_order_2_values = np.array([sem(xx, NU0, SIGMA0, 2) for xx in x]) |
| |
| dict | plot_data |
| |
Singular Euler-Maclaurin (SEM) expansion for a Gaussian function in 1D.
This script demonstrates the application of the Singular Euler-Maclaurin
expansion to a Gaussian function in one dimension. It calculates and compares
the integral, sum, and SEM approximations for various orders:
sum = ∑_{y ∈ ℤ, y ≠ x} g(y) / |y − x|^ν
integral = ∫_{y ∈ ℝ} g(y) / |y − x|^ν dy
SEM(order) ≈ sum − integral
We skip the summand y = x so that the sum is well-defined. Here, g denotes the Gaussian:
g(y) = exp(−π y² / σ²)
We choose σ = 100 to ensure fast convergence of the direct sum. The integral is calculated via:
integral = 2^ν (σ² / π)^(1 − ν⁄2) Γ(1 − ν) Γ(ν⁄2) ₁F₁(ν⁄2, ½, −(π x² / σ²)) sin(π ν⁄2)
where ₁F₁ is the confluent hypergeometric function and Γ is the Gamma function. In cases where ν
is a non-negative integer or a negative even integer, the integral is calculated by extrapolating
from nearby ν-values.
The SEM of some order is calculated as:
SEM(order) = ∑_{α ∈ {0, 2, …, order}} 1 / (α! (−2πi)^|α|) Z_{Λ,ν}^{reg,(α)}{x}{y=0} g^{(α)}(x)
similar to equation (8) in (*), where (α) denotes differentiation with respect to y, and the
derivatives of the regularized Epstein zeta function are computed using finite differences.
(*): Andreas A. Buchheit et al. “Exact Continuum Representation of Long-range Interacting Systems
and Emerging Exotic Phases in Unconventional Superconductors”, Phys. Rev. Research 5, 043065 (2023)
Usage:
python sem_gaussian_1d.py [--nu NU]
Arguments:
--nu NU Optional. Set the value of ν for calculations. Default is 1.5.
Example: python sem_gaussian_1d.py --nu 1
The script generates plots comparing the different approximations and their
errors for the specified ν value.