June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1 +1 @@
|
|||
gamma(x)
|
||||
@show gamma(1)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
gamma_quad(t) = quadgk(x -> x^(t-1)*exp(-x), zero(t), inf(t), reltol=100*eps(t))[1]
|
||||
|
||||
# generalize to handle arrays of inputs:
|
||||
@vectorize_1arg Real gamma_quad
|
||||
using QuadGK
|
||||
gammaquad(t::Float64) = first(quadgk(x -> x ^ (t - 1) * exp(-x), zero(t), Inf, reltol = 100eps(t)))
|
||||
@show gammaquad(1.0)
|
||||
|
|
|
|||
4
Task/Gamma-function/Maple/gamma-function.maple
Normal file
4
Task/Gamma-function/Maple/gamma-function.maple
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
GAMMA(17/2);
|
||||
GAMMA(7*I);
|
||||
M := Matrix(2, 3, 'fill' = -3.6);
|
||||
MTM:-gamma(M);
|
||||
42
Task/Gamma-function/Stata/gamma-function.stata
Normal file
42
Task/Gamma-function/Stata/gamma-function.stata
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
mata
|
||||
_gamma_coef = 1.0,
|
||||
5.7721566490153286061e-1,-6.5587807152025388108e-1,
|
||||
-4.2002635034095235529e-2,1.665386113822914895e-1,
|
||||
-4.2197734555544336748e-2,-9.6219715278769735621e-3,
|
||||
7.2189432466630995424e-3,-1.1651675918590651121e-3,
|
||||
-2.1524167411495097282e-4,1.2805028238811618615e-4,
|
||||
-2.0134854780788238656e-5,-1.2504934821426706573e-6,
|
||||
1.1330272319816958824e-6,-2.0563384169776071035e-7,
|
||||
6.1160951044814158179e-9,5.0020076444692229301e-9,
|
||||
-1.1812745704870201446e-9,1.0434267116911005105e-10,
|
||||
7.782263439905071254e-12,-3.6968056186422057082e-12,
|
||||
5.100370287454475979e-13,-2.0583260535665067832e-14,
|
||||
-5.3481225394230179824e-15
|
||||
|
||||
function gamma_(x_) {
|
||||
external _gamma_coef
|
||||
x = x_
|
||||
for (y=1; x>2;) y = --x*y
|
||||
z = _gamma_coef[24]
|
||||
x--
|
||||
for (i=23; i>=1; i--) z = z*x+_gamma_coef[i]
|
||||
return(y/z)
|
||||
}
|
||||
|
||||
function map(f,a) {
|
||||
n = rows(a)
|
||||
p = cols(a)
|
||||
b = J(n,p,.)
|
||||
for (i=1; i<=n; i++) {
|
||||
for (j=1; j<=p; j++) {
|
||||
b[i,j] = (*f)(a[i,j])
|
||||
}
|
||||
}
|
||||
return(b)
|
||||
}
|
||||
|
||||
x=(1::10000)/100
|
||||
u=map(&gamma(),x)
|
||||
v=map(&gamma_(),x)
|
||||
max(abs((u-v):/u))
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue