#C6.txt: Feb. 10, 2014, the joy of guessing Help:=proc(): print(`Hn(n) , HnS(N), Hnr(n,r), HnrS(r,N)`): print( ` Ratio1(L) , GuessRF1(L,d,n)`): print(`GuessRF(L,n) `): end: with(linalg): #Hnr(n,r): the determinant of the generalized Hilbert n by n matrix #whose (1,1) entry is not 1 by 1/(r+1) Hnr:=proc(n,r) local i,j: det([seq([seq(1/(i+j-1+r),j=1..n)],i=1..n)]): end: #Hn(n): the determinant of the famous Hilbert n by n matrix Hn:=proc(n) local i,j: det([seq([seq(1/(i+j-1),j=1..n)],i=1..n)]): end: #The first N terms of Hn, starting at n=1 HnS:=proc(N) local n: [seq(Hn(n), n=1..N)]: end: #The first N terms of Hn, starting at n=1 HnrS:=proc(r,N) local n: [seq(Hnr(n,r), n=1..N)]: end: #Ratio1(L): inputs a list L and outputs the list of L[i+1]/L[i] Ratio1:=proc(L) local i: [seq(L[i+1]/L[i],i=1..nops(L)-1)]; end: #GuessRF1(L,d,n): inputs a list of numbers (or expressions) #L, a non-neg. integer d, and a (discrete) variable name #n and tries to guess a rational function of n of degree #d, such that L[i]-R(i)=0 for all i from 1 to nops(L) GuessRF1:=proc(L,d,n) local R,a,b,i,j,eq,var: if nops(L)<=2*d+6 then print(`Make list bigger`): RETURN(FAIL): fi: R:=(n^d+add(a[i]*n^i,i=0..d-1))/add(b[j]*n^j,j=0..d): var:={seq(a[i],i=0..d-1), seq(b[j],j=0..d)}: eq:={seq( numer(L[i]-subs(n=i,R)) =0,i=1..2*d+6)}: var:=solve(eq,var): if var=NULL then RETURN(FAIL): fi: R:=subs(var , R): if {seq( numer(L[i]-subs(n=i,R)),i=1..nops(L))}<>{0} then print(`It worked up to`, 2*d+6, `terms, but that's life `): FAIL: else R: fi: end: #GuessRF(L,n): inputs a list of numbers (or expressions) #L, and a (discrete) variable name #n and tries to guess a rational function of n of degree #<=(nops(L)-6)/2 such that L[i]-R(i)=0 for all i from 1 to nops(L) GuessRF:=proc(L,n) local d, katie: for d from 0 to (nops(L)-6)/2 do katie:=GuessRF1(L,d,n): if katie<>FAIL then RETURN(katie): fi: od: FAIL: end: