#Feb. 15, 2016, C8.txt, Proving irrationality Help:=proc(): print(`Z(F,k,n) , PRecToSeq(R,n,N), PRecToSeqW(R,n,N,w), SumF(F,k,n,n0)`): end: #Z(F,k,n): inputs an expression inolving binomial coefficients in k and n #outputs a P-recursive description of the sequence #Sum(F(k,n),k=0..n); Using the Zeilberger algorithm. Z:=proc(F,k,n) local N,ope, Ord,rec,i,n0,k0,ini: ope:=SumTools[Hypergeometric][Zeilberger](F,n,k,N)[1]: Ord:=degree(ope,N): ope:=expand(subs(n=n-Ord,ope)/N^Ord): ope:=add(factor(coeff(ope,N,-i))*N^(-i),i=0..Ord): ope:=ope/coeff(ope,N,0): rec:=[-seq(coeff(ope,N,-i),i=1..Ord)]: ini:=[seq( eval(add( subs({n=n0,k=k0},F),k0=0..n0)) ,n0=1..Ord)]: [ini,rec]: end: #PRecToSeq(R,n,N): inputs a P-recursive sequence [ini,rec(n)] where ini is a list #of numbers of length k say, and rec is a list of coefficients of the #P-recursive sequence defined UNIQELY by #x(n)=ini[n], for n=1..k #and rec is a list of numbers [c1(n),c2(n),...,ck(n)] #and for n>=k defined recursively by #x(n)=c1(n)*x(n-1)+c2(n)*x(n-2)+...+ck(n)*x(n-k). #For example the sequence 2^n is coded as #[[1],[2]], and the sequence of Fib. numbers are given by #[[0,1],[1,1]] #It outputs the list consisting of the first N terms of that sequence starting at n=0 PRecToSeq:=proc(R,n,N) local ini,rec,Se,k,n0,nt,i: ini:=R[1]: rec:=R[2]: k:=nops(ini): if nops(rec)<>k then RETURN(FAIL): fi: Se:=ini: for n0 from k+1 to N do #nt:=c1(n0)*Se[n0-1]+c2(n0)*Se[n0-2]+...+ ck(n0)*Se[n0-k] nt:=add(subs(n=n0,rec[i])*Se[n0-i],i=1..k): Se:=[op(Se),nt]: od: Se: end: #RecToSeqW(R,N,w): inputs a C-finite sequence [ini,rec] where ini is a list #of numbers of length k say, and rec is a list of coefficients of the #C-finite sequence defined UNIQELY by #x(n)=ini[n+1], for n=0..k-1, #and rec is a list of numbers [c1,c2,...,ck] #and for n>=k defined recursively by #x(n)=c1*x(n-1)+c2*x(n-2)+...+ck*x(n-k). #For example the sequence 2^n is coded as #[[1],[2]], and the sequence of Fib. numbers are given by #[[0,1],[1,1]] #It outputs the list consisting of the terms N-w+1 through w of that sequence starting at n=N-w+1 RecToSeqW:=proc(R,N,w) local ini,rec,Se,k,n,nt,i: ini:=R[1]: rec:=R[2]: k:=nops(ini): if nops(rec)<>k then RETURN(FAIL): fi: if w=k defined recursively by #x(n)=c1*x(n-1)+c2*x(n-2)+...+ck*x(n-k). #For example the sequence 2^n is coded as #[[1],[2]], and the sequence of Fib. numbers are given by #[[0,1],[1,1]] #It outputs the list consisting of the terms N-w+1 through w of that sequence starting at n=N-w+1 PRecToSeqW:=proc(R,n,N,w) local ini,rec,Se,k,n0,nt,i: ini:=R[1]: rec:=R[2]: k:=nops(ini): if nops(rec)<>k then RETURN(FAIL): fi: if w