#Nathan Fox #Homework 9 #I give permission for this work to be posted online #Read procedures from class read(`hw6.txt`): read(`C9.txt`): Help:=proc(): print(` ApplyUmbra(P,x,U,m) , PnG(n,x,U,m) , GuessCoeff(n,i,U,m) `): end: ##PROBLEM 1## #ApplyUmbra(P,x,U,m): inputs a polynomial expression P in the #variable x, a variable x, an expression U in m, and a #discrete variable m, where U describes the umbra #x^m -> U(m) #and extended by linearity, and outputs the value when the #umbra U is applied to P. ApplyUmbra:=proc(P, x, U, m) local i, val: return add(coeff(P, x, i)*subs(m=i, U), i=0..degree(P, x)): end: ##PROBLEM 2## #PnG(n,x,U,m): inputs a non-neg. integer n, a variable name x, #an expression U in the discrete variable m, and the variable m, #and outputs the unique monic polynomial, P, of degree n such that #when U is applied to the polynomials P*x^i (i=0..n-1), #you would get zero. PnG:=proc(n, x, U, m) local eq, var, i, P, a: P:=x^n+add(a[i]*x^i, i=0..n-1): var:={seq(a[i], i=0..n-1)}: eq:={seq(ApplyUmbra(P*x^i, x, U, m), i=0..n-1)}: return sort(subs(solve(eq, var), P)): end: #{seq(evalb(PnG(n,x,1/(m+1),m)=Pn(n,x)),n=0..10)}; #returned {true}, as it should have ##PROBLEM 3## #GuessCoeff(n,i,U,m): inputs a discrete variable n, #a non-negative integer i, an expression U (describing an umbra) #in m, and a variable name m, and guesses a rational function #in n for the coefficient of x^(n-i) in PnG(n,x,U,m). #WARNING: runs forever if no rational function GuessCoeff:=proc(n, i, U, m) local rat, ps, j, cap: cap:=[0, 16]: ps:=[]: while true do ps:=[op(ps), seq(PnG(j, x, U, m), j=cap[1]+1..cap[2])]: rat:=MyGuessRF([seq(coeff(ps[j], x, j-i), j=1..nops(ps))], n): if rat <> FAIL then return rat: fi: cap:=[cap[2], cap[2]*2]: od: end: #1/(m+1): #i=0, function=1 #i=1, function=-1/2*n #i=2, function=(n^3+n-2*n^2)/(-4+8*n) #i=3, function=(n^4-4*n+8*n^2-5*n^3)/(24-48*n) #i=4, function=(n^6-36*n+96*n^2-97*n^3+47*n^4-11*n^5)/(288-768*n+384*n^2) #i=5, function=(n^7+288*n-768*n^2+794*n^3-415*n^4+117*n^5-17*n^6)/(-2880+7680*n-3840*n^2) #i=6, function=(n^9+7200*n-22080*n^2+27818*n^3-19083*n^4+7869*n^5-2010*n^6+312*n^7-27*n^8)/(-86400+264960*n-207360*n^2+46080*n^3) #i=7, function=(n^10-86400*n+264960*n^2-336216*n^3+235556*n^4-101514*n^5+28119*n^6-5034*n^7+564*n^8-36*n^9)/(1209600-3709440*n+2903040*n^2-645120*n^3) #1/(m+3): #i=0, function=1 #i=1, function=(n^2+2*n)/(-2-2*n) #i=2, function=(n^3-2*n+n^2)/(4+8*n) #i=3, function=(n^4+4*n-4*n^2-n^3)/(-24-48*n) #i=4, function=(n^6+12*n-28*n^2+17*n^3+3*n^4-5*n^5)/(-96+384*n^2) #i=5, function=(n^7-96*n+200*n^2-116*n^3-10*n^4+31*n^5-10*n^6)/(960-3840*n^2) #i=6, function=(n^9-1440*n+3768*n^2-3436*n^3+978*n^4+429*n^5-408*n^6+126*n^7-18*n^8)/(17280-11520*n-69120*n^2+46080*n^3) #i=7, function=(n^10+17280*n-43776*n^2+38904*n^3-11348*n^4-4214*n^5+4445*n^6-1544*n^7+278*n^8-26*n^9)/(-241920+161280*n+967680*n^2-645120*n^3) #eval(m!): #i=0, function=1 #i=1, takes a really long time (and all higher values of i too)