September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
39
Task/Gamma-function/Phix/gamma-function.phix
Normal file
39
Task/Gamma-function/Phix/gamma-function.phix
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
sequence c = repeat(0,12)
|
||||
|
||||
function gamma(atom z)
|
||||
atom accm = c[1]
|
||||
if accm=0 then
|
||||
accm = sqrt(2*PI)
|
||||
c[1] = accm
|
||||
atom k1_factrl = 1 -- (k - 1)!*(-1)^k with 0!==1
|
||||
for k=2 to 12 do
|
||||
c[k] = exp(13-k)*power(13-k,k-1.5)/k1_factrl
|
||||
k1_factrl *= -(k-1)
|
||||
end for
|
||||
end if
|
||||
for k=2 to 12 do
|
||||
accm += c[k]/(z+k-1)
|
||||
end for
|
||||
accm *= exp(-(z+12))*power(z+12,z+0.5) -- Gamma(z+1)
|
||||
return accm/z
|
||||
end function
|
||||
|
||||
procedure sq(atom x, atom mul)
|
||||
atom p = x*mul
|
||||
printf(1,"%18.16g,%18.15g\n",{x,p*p})
|
||||
end procedure
|
||||
|
||||
procedure si(atom x)
|
||||
printf(1,"%18.15f\n",{x})
|
||||
end procedure
|
||||
|
||||
sq(gamma(-3/2),3/4)
|
||||
sq(gamma(-1/2),-1/2)
|
||||
sq(gamma(1/2),1)
|
||||
si(gamma(1))
|
||||
sq(gamma(3/2),2)
|
||||
si(gamma(2))
|
||||
sq(gamma(5/2),4/3)
|
||||
si(gamma(3))
|
||||
sq(gamma(7/2),8/15)
|
||||
si(gamma(4))
|
||||
Loading…
Add table
Add a link
Reference in a new issue