Calculate double factorial with BigInt
This commit is contained in:
parent
761216d32f
commit
5ffa215c57
|
|
@ -1,7 +1,7 @@
|
||||||
using LinearAlgebra, DelimitedFiles
|
using LinearAlgebra, DelimitedFiles
|
||||||
|
|
||||||
"Sum over array while minimizing catastrophic cancellation as much as possible"
|
"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]
|
pos_arr = arr[arr .> 0]
|
||||||
neg_arr = arr[arr .< 0]
|
neg_arr = arr[arr .< 0]
|
||||||
|
|
||||||
|
|
|
||||||
2
math.jl
2
math.jl
|
|
@ -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)
|
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
|
# 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)"
|
"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)
|
gauss_int(a, n) = double_factorial(n - 1) / (2 * a)^((n + 1)/2) * (iseven(n) ? sqrt(π / 2) : 1)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue