Calculate double factorial with BigInt

This commit is contained in:
Nuwan Yapa 2024-10-29 17:30:25 -04:00
parent 761216d32f
commit 5ffa215c57
2 changed files with 2 additions and 2 deletions

View File

@ -1,7 +1,7 @@
using LinearAlgebra, DelimitedFiles
"Sum over array while minimizing catastrophic cancellation as much as possible"
function better_sum(arr::Array{Float64})
function better_sum(arr::Array{T}) where T<:Real
pos_arr = arr[arr .> 0]
neg_arr = arr[arr .< 0]

View File

@ -15,7 +15,7 @@ laguerre(l, n, x) = gamma(n + l + 3/2) * better_sum([(-x * x)^k / gamma(k + l +
ho_basis(l, n, x) = (-1)^n / sqrt_sqrt_pi * 2^((n + l + 2) / 2) * sqrt_factorial(n) / sqrt_double_factorial(2*n + 2*l + 1) * x^(l + 1) * exp(-x^2 / 2) * laguerre(l, n, x)
# for implementation of simple relative coordinates
double_factorial(n) = Iterators.prod(Float64, n:-2:1)
double_factorial(n::Int) = Iterators.prod(big, n:-2:1)
"Gaussian integral for n ∈ Integers (Ref: Wolfram MathWorld + simplifications)"
gauss_int(a, n) = double_factorial(n - 1) / (2 * a)^((n + 1)/2) * (iseven(n) ? sqrt(π / 2) : 1)