hi Bob and Dan
Bob, Octave does much beter than thinBasic, Dan, I did change the script to make it work.
anyway, you can also drop the first column in the matrix and just make the first coefficient = 1,
(also decrease the size of the dimensions by one) the rest of the coefficients will differ
slightly because of this change, but it approximates the gamma function almost as well, (it needs to be checked).
example thinBasic script, look carefully for the changes.
Uses "console"
Uses "math"
Const n = 6
Dim As Ext g = 5
Dim As Ext a(n,n), b(n,n), c(n,1)
Dim As Integer i, j
'for n = 6, the following sets up matrix a as:
' [[ 1, 1/2, 1/3, 1/4, 1/5, 1/6 ]
' [ 1/2, 1/3, 1/4, 1/5, 1/6, 1/7 ]
' [ 1/3, 1/4, 1/5, 1/6, 1/7, 1/8 ]
' [ 1/4, 1/5, 1/6, 1/7, 1/8, 1/9 ]
' [ 1/5, 1/6, 1/7, 1/8, 1/9, 1/10 ]
' [ 1/6, 1/7, 1/8, 1/9, 1/10, 1/11 ]]
For i=1 To n
'<< note the change
For j=1 To n '<< note the change
a(i,j)=1/(i+j-1) '<< note the change
Next
Next
For i=1 To n
c(i,1) = Factorial(i-1)/((i+g-0.5)^(i-0.5)/Exp(i+g-0.5)*Sqr(2*M_PI))-1 '<< note the change
Next
MAT b() = INV(a())
MAT a() = b() * c()
Console_WriteLine "C( 1) = 1"
For i=1 To n
Console_WriteLine "C("&Str$(i+1)&") = "&a(i,1)
Next
Console_WriteLine "All done. Press any key to finish"
Console_WaitKey
here are the coefficients as calculated with Maple
c[0] := 1
c[1] := 76.180091728331374539146745
c[2] := -86.505320289513654614503042
c[3] := 24.014097921606006186204527
c[4] := -1.2317386147754424755938420
c[5] := .120745388047503859955038e-2
c[6] := -.4868518292851569517614e-5
Bookmarks