(*                            Ren-Cang Li, June 1, 1996
                              na.rcli@na-net.ornl.gov   *)

y=( t   a1 X 
   +t   b1 Y
   +t^3 a3 a3Cmt
   +t^3 b3 b3Cmt
   +t^5 a5 a5Cmt
   +t^5 b5 b5Cmt
   +t^5 c5 c5Cmt
   +t^5 d5 d5Cmt
   +t^5 e5 e5Cmt
   +t^5 f5 f5Cmt
   +t^7 a7 a7Cmt
   +t^7 b7 b7Cmt
   +t^7 c7 c7Cmt
   +t^7 d7 d7Cmt
   +t^7 e7 e7Cmt
   +t^7 f7 f7Cmt
   +t^7 g7 g7Cmt
   +t^7 h7 h7Cmt
   +t^7 i7 i7Cmt
   +t^7 j7 j7Cmt
   +t^7 k7 k7Cmt
   +t^7 l7 l7Cmt
   +t^7 m7 m7Cmt
   +t^7 n7 n7Cmt
   +t^7 o7 o7Cmt
   +t^7 p7 p7Cmt
   +t^7 q7 q7Cmt
   +t^7 r7 r7Cmt );
y=Expand[Normal[Series[y,{t,0,DEGREE}]]];

w=( t   newa1 X 
   +t   newb1 Y
   +t^3 newa3 a3Cmt
   +t^3 newb3 b3Cmt
   +t^5 newa5 a5Cmt
   +t^5 newb5 b5Cmt
   +t^5 newc5 c5Cmt
   +t^5 newd5 d5Cmt
   +t^5 newe5 e5Cmt
   +t^5 newf5 f5Cmt
   +t^7 newa7 a7Cmt
   +t^7 newb7 b7Cmt
   +t^7 newc7 c7Cmt
   +t^7 newd7 d7Cmt
   +t^7 newe7 e7Cmt
   +t^7 newf7 f7Cmt
   +t^7 newg7 g7Cmt
   +t^7 newh7 h7Cmt
   +t^7 newi7 i7Cmt
   +t^7 newj7 j7Cmt
   +t^7 newk7 k7Cmt
   +t^7 newl7 l7Cmt
   +t^7 newm7 m7Cmt
   +t^7 newn7 n7Cmt
   +t^7 newo7 o7Cmt
   +t^7 newp7 p7Cmt
   +t^7 newq7 q7Cmt
   +t^7 newr7 r7Cmt );
w=Expand[Normal[Series[w,{t,0,DEGREE}]]];

MmPoly[p_,q_]:=Block[{coefp=CoefficientList[p,t],coefq=CoefficientList[q,t],
		  pq, k, i},
		 pq=Expand[coefp[[1]] q+p coefq[[1]]- coefp[[1]] coefq[[1]]];
                 Do[{pq=pq+Expand[Sum[Mm[coefp[[i]], 
                                         coefq[[k+2-i]]],{i,2,k}]] t^k},
                    {k,2,DEGREE}];
		 pq];

Print["Compute exp(x) = exp(d t X)"];
termx=x; tmpn=1; tmpx=x;
Do[{tmpx=Mm[tmpx,x];
	tmpn=ii tmpn; termx=termx+Expand[tmpx/tmpn]}, {ii,2,DEGREE}];
termx=1+termx;

Print["Compute exp(y)"];
termy=y; tmpn=1; tmpy=y;
Do[{tmpy=Expand[Normal[Series[Mm[tmpy,y],{t,0,DEGREE}]]];
	tmpn=ii tmpn; termy=termy+Expand[tmpy/tmpn]}, {ii,2,DEGREE}];
termy=1+termy;

Print["Compute exp(w)"];
termw=w; tmpn=1; tmpw=w;
Do[{tmpw=Expand[Normal[Series[Mm[tmpw,w],{t,0,DEGREE}]]];
	tmpn=ii tmpn; termw=termw+Expand[tmpw/tmpn]}, {ii,2,DEGREE}];
termw=1+termw;

Print["Compute exp(x)exp(y)exp(x)"];
termxyx=MmPoly[termx,termy];
termxyx=MmPoly[termxyx,termx]; 

Print["Compute Error"];
error=Expand[termxyx-termw];
If[error==0,
   Print["Correctness is verified"],
   Print["Correctness is NOT verified"]];
