#hw3.txt: Jan 31, 2014. Katie McKeon Help:=proc() print(`inv1(p) gf(n,p)`): end: #Examples from Garvan's Maple Book #Differential Equations f:='f': y:=f(x); dy:=diff(y,x); ddy:=diff(%,x); dsolve(ddy+5*dy+6*y=sin(x)*exp(-3*x),y); #Graphics with(plots): polarplot(cos(5*t), t=0..2*Pi); L:=[[0,0],[1,1],[2,3],[3,2],[4,-2]]: plot(L, style=point, title='Points'); animate3d([r*cos(t+a),r*sin(t+a),r^2*cos(2*t)+sin(a)],r=0..1,t=0..2*Pi,a=0..2*Pi,frames=10,style=patch,title=`The Flying Pizza`); #Problem 2 - the dangers of floating point calculations with(linalg): read`C3.txt`: Digits:=10: evalf(det(Hil(50))), det(evalf(Hil(50))); #The smallest "good" digit approximations for the Hilbert matrices are listed below #Hil(10) - 16 Digits #Hil(20) - 32 Digits #Hil(30) - 48 Digits #Hil(40) - 64 Digits #Hil(50) - 78 Digits #Hil(60) - 94 Digits #Hil(70) - 108 Digits #Hil(80) - 120 Digits #Hil(90) - 138 Digits #Hil(100) - 154 Digits #It appears that there is a linear relationship between the size #of the Hilbert matrix and the number of digit places needed to #approximate its determinant accurately. In particular, as the #rows and columns of the matrix increase by ten, the digits must #increase by roughly 16. #inv1(p) takes a permutation and outputs the number of its inversions inv1:=proc(p) local i,j,n,s: s:=0: n:=nops(p): for i from 1 to n do for j from i+1 to n do if p[i] > p[j] then s:=s+1: fi: od: od: s: end: #gf(n,q) takes two integers n, q and computes the sum of #q^(number of inversions of p) for every permutation p #of length n gf:=proc(n,q) local s,P,i: s:=0: P:=permute(n): for i from 1 to factorial(n) do s:=s+q^(inv1(P[i])): od: s: end: #Problem 3. Predict a nice formula for gf(n,q): #based on the cases n=1,...,8 it appears that #gf(n,q)/gf(n-1,q) = q^(n-1)+q^(n-1)+...+q+1 #this gives the conjectured recursive formula #gf(n,q) = gf(n-1,q) (q^(n-1)+q^(n-1)+...+q+1) with gf(1,q)=1