05-19-2024, 05:13 AM
and here's the gamma reciprocal
Code: (Select All)
_Title "gamma_inv function test"
Dim As Long i
For i = 1 To 20
Print i, gamma_inv(i)
Next
Function gamma_inv# (x_in As Double)
Static As Double d(20), f, sum, x, z
x = x_in
d(1) = 1
d(2) = -0.08333333333339432
d(3) = 0.003472222229927532
d(4) = 0.002681326782003515
d(5) = -0.0002294625761279813
d(6) = -0.0007841775716605252
d(7) = 7.093133582704529E-05
d(8) = 0.0005865361360167114
d(9) = -5.038235546703003E-05
d(10) = -0.0006597591049770531
d(11) = -0.001339314419184738
d(12) = 0.008102207604020538
d(13) = -0.01770764460311748
d(14) = 0.02454011794984818
d(15) = -0.02403014074759222
d(16) = 0.01704015119564821
d(17) = -0.008632563394507144
d(18) = 0.002976937308522899
d(19) = -0.000627846535400408
d(20) = 6.120299540340159E-05
z = 0.3989422804014327 * x ^ (.5 - x) * Exp(x)
f = x * x: f = f * f: f = f * f * x: f = f * f * x 'f = x^19
sum=(d(20)*z+(d(19)*z+(d(18)*z+(d(17)*z+(d(16)*z+(d(15)*z+(d(14)*z _
+(d(13)*z+(d(12)*z+(d(11)*z+(d(10)*z+(d(9)*z+(d(8)*z+(d(7)*z+(d(6)* _
z+(d(5)*z+(d(4)*z+(d(3)*z+(x*z*d(1)+z*d(2))*x)*x)*x)*x)*x)*x)*x)*x) _
*x)*x)*x)*x)*x)*x)*x)*x)*x)*x)/f
gamma_inv = sum
End Function