#hw6.txt, 2/13/14, Anthony Zaleski #Note: to use this file, C6.txt must be in the same directory. read("C6.txt"): Help1:=proc(): Help(): print(`GuessRatioRatio(a,n,r),MyGuessRF1(L,d1,d2,n),MyGuessRG(L,n),GuessDoubleRF1(L,dm,dn,dB,m,n),GuessDoubleRF(L,m,n) `): end: ##########Problem 1: GuessRatioRatio(a,n,r)########## #GuessRatioRatio(a,n,r): inputs expression a in the variable n #and a variable r. For each n, define an nxn matrix H(n,r) #s.t. H(n,r)[i][j]=a(i+j-1+r) and define h(n,r)=det(H(n,r)). #Outputs a rational function in n (with coefficients involving r) #which is a guess for (h(n+2,r)/h(n+1,r))/(h(n+1,r)/h(n,r)). #To get data for the guess, computes h(n,r) for n=1..N=20. GuessRatioRatio:=proc(a,n,r) local N,hs,nn,i,j,L: N:=20: hs:=[seq(det([seq([seq(subs(n=i+j-1+r,a),j=1..nn)],i=1..nn)]),nn=1..N)]: L:=Ratio1(Ratio1(hs)): GuessRF(L,n): end: ##########Problem 2: ProveConj(Exp,n,r)########## #ProveConj(Exp,n,r): inputs Exp, an expression in terms of #n and r which is the conjectured formula for #(h(n+2,r)/h(n+1,r))/(h(n+1,r)/h(n,r)). Outputs 1 if #The formula is correct, 0 otherwise. #To determine output, we use induction. We already know #The formula holds for n=1. Assume it holds for all #n{0} then print(`It worked up to`, 2d1+d2+6, `terms, but that's life `): FAIL: else R: fi: end: #MyGuessRG(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) MyGuessRG:=proc(L,n) local dmax,d1,d2, R: dmax:=nops(L)-6: # the max of d1+d2 if dmax<=0 then print(`Need at least 7 elements in L.`); return FAIL: fi: for d1 from 0 to dmax do for d2 from 0 to dmax-d1 do R:=MyGuessRF1(L,d1,d2,n): if R<>FAIL then RETURN(R): fi: od: od: FAIL: end: ##########Problem 5: guessing rational functions of m,n########## #GuessDoubleRF1(L,dm,dn,dB,m,n): inputs double list L and variables m,n; #outputs a rational function R in m,n s.t. R(i,j)=L[i][j]. #The numerator will have leading term m^dm*n^dn and the bottom #will have degree <=dB. #IMPORTANT: currently this uses ALL elements of L to build #a set of equations. You may want to change this because of #computation time or a Maple bug. To use less equations, #set Neq:=Nvar+n, where n is some fixed number <=30. GuessDoubleRF1:=proc(L,dm,dn,dB,m,n) local dT,Nvar,Lrows,Lcols,Rnumer,Rdenom,R,i,j,Nrows,Neq,eq,var: dT:=dm+dn: #The number of variables will be #|{(i,j):0<=i+j<=dT}| - 1 + |{(i,j):0<=i+j<=dB}| #=(1+2+...+(dT+1))-1+(1+2+...+(dB+1)) #=(dT+1)*(dT+2)/2-1+(dB+1)*(dB+2)/2. Lrows:=nops(L): Lcols:=nops(L[1]): Nvar:=(dT+1)*(dT+2)/2-1+(dB+1)*(dB+2)/2: #NOTE: currently I set Neq to be the number of elements in L!!! Neq:=Lrows*Lcols: #Nvar+30: if Lrows*Lcols{0} then print(`GuessDoubleRF1 didn't work for the whole list.`): return(FAIL): else R: fi: else R: fi: end: #GuessDoubleRF(L,m,n): inputs double list L and variables m,n; #outputs a rational function R in m,n s.t. R(i,j)=L[i][j]. GuessDoubleRF:=proc(L,m,n) local dT,NL,dB,dm,dn,R: dT:=0: NL:=nops(L)*nops(L[1]): #In the following messy nest, the outer while loop #loops over dT, the degree of the top; the inner while #loops over dB, the degree of the bottom; and the two #for loops loop over the possible leading terms in #the top. while (dT+1)*(dT+2)/2-1+31<=NL do dB:=0: while (dT+1)*(dT+2)/2-1+(dB+1)*(dB+2)/2+30<=NL do for dm from 0 to dT do for dn from 0 to dT-dm do R:=GuessDoubleRF1(L,dm,dn,dB,m,n): if R<>FAIL then return(R): fi: od: od: dB:=dB+1: od: dT:=dT+1 od: FAIL: end: