Help:=proc(): print(` , Orth(n,x,w,a,b), Rat(Li,a,x)`): print(`GuessHG(R,j)`): print(`GuessCoe(n,x,w,A,B,k) , GuessOrtho(n,x,w,A,B,L,j) `): end: #Ortho(n,x,w,A,B): inputs a positive integer n and a symbol x #and a (continuous) weight-function w (an expression in x) #and numbers A and B #outputs the polynomial P(x) of degree n in x such that #int(x^i*P(x)*w,x=A..B)=0 for i=0,1,...,n Ortho:=proc(n,x,w,A,B) local P,eq,var,a,i: option remember: P:=add(a[i]*x^i,i=0..n): var:={seq(a[i],i=0..n)}: eq:={a[0]=1,seq(int(x^i*P*w,x=A..B)=0,i=0..n-1)}: P:=subs(solve(eq,var),P): end: GuessCoe:=proc(n,x,w,A,B,k) local Li,n1: option remember: Li:=[seq(coeff(Ortho(n1,x,w,A,B),x,k),n1=k..4*k+4)]: Rat(Li,k,n): end: GuessOrtho:=proc(n,x,w,A,B,L,j) local k,Li: Li:=[seq(GuessCoe(n,x,w,A,B,k),k=0..L)]: Li:=[seq(Li[i+1]/Li[i],i=1..nops(Li)-1)]: GuessHG(Rat(Li,0,j),j): end: #PolF2(Li,a,d1,d2,x): tries to fit a rational function #f(x) = P(x)/Q(x) with deg P(x) = d1, deg Q(x)= d2, #in x, such that f(a)=Li[1], #f(a+1)=Li[2],...f(a+nops(Li)-1)=Li[nops(Li)] #and FAIL otherwise PolF2:=proc(Li,a,d1,d2,x) local f,g,c1,c2,i,var,eq, sol: f:=add(c1[i]*x^i,i=0..d1): g:=add(c2[i]*x^i,i=0..d2): var:={seq(c1[i],i=0..d1),seq(c2[i],i=0..d2)}: eq:={seq(subs(x=a+i-1,f)/subs(x=a+i-1,g)=Li[i],i=1..nops(Li))}: sol:=solve(eq,var): if sol=NULL then RETURN(FAIL): fi: normal(subs(sol,f)/subs(sol,g)): end: #determines the lowest degree polynomial that PolF2 doesn't return FAIL #and returns the desired rational function Rat:=proc(Li,a,x) local d1,d2,f: for d1 from 0 to nops(Li)-3 do for d2 from 1 to nops(Li)-3-d1 do f:=PolF2(Li,a,d1,d2,x): if f<>FAIL then RETURN(f): fi: od: od: FAIL: end: #GuessHG: inputs a rational function R, and outputs the #hypergeometric expression such that a(0)=1 GuessHG:=proc(R,j) local a: rsolve( { a(j)=R*a(j-1), a(0)=1}, a(j)): end: