(*This Mathematica file computes the bounds on the 8th derivatives of the Hessian.
This is the term M_8 in chapter 6 of the paper.  This file is essentially
taking the combinatiral operation of summing the absolute values of
the cofficients of the relevant derivative. We take all possible derivatives
and then take the max sum*)

(*Here is the basic function*)

g[a_,b_,c_,d_]:= (4*(1+2*a*c+a^2*c^2+b^2*c^2+2*b*d+a^2*d^2+b^2*d^2))/((1+a^2+b^2)*(1+c^2+d^2))

(*This computes D_1^(i1)D_2^(i2)D_3^(i3)D_4^(8-i1-i2-i3)G.
  That is, it computes an arbitrary 8th partial*)

DG[j1_,j2_,j3_,k_]:=(
P1=D[Power[g[a,b,c,d],k],{a,j1},{b,j2},{c,j3},{d,8-j1-j2-j3}];
P2=Power[1+a a+b b,k+j1+j2] Power[1+c c + d d,k+8-j1-j2] P1;
P3=Expand[Together[P2]];
P4=Table[P3[[q]],{q,1,Length[P3]}];
a=1;b=1;c=1;d=1;
P5=P4;
Clear[a,b,c,d];
P6=Abs[P5];
Sum[P6[[q]],{q,1,Length[P6]}])


(*Here we are taking the maximum over all 8th partials of f and
the maximum over all 8th partials of g.  The two examples we
need are when EX=6 and when EX=10. So, you would run MaxG[6] and
MaxG[10] to get the bounds from the paper.  It turns out that
the answers are the same as DG[8,0,0,6] and DG[8,0,0,10].
You can try these first to see what you will get after the
long wait.*)

MaxG[EX_]:=Max[Flatten[Table[Table[Table[DG[j1,j2,j3,EX],{j1,0,8-j2-j3}],{j2,0,8-j3}],{j3,0,8}]]]

