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

y=( t   a1 X 
   +t   b1 Y
   +t^2 a2 a2Cmt
   +t^3 a3 a3Cmt
   +t^3 b3 b3Cmt
   +t^4 a4 a4Cmt
   +t^4 b4 b4Cmt
   +t^5 a5 a5Cmt
   +t^5 b5 b5Cmt
   +t^5 c5 c5Cmt
   +t^5 d5 d5Cmt
   +t^6 a6 a6Cmt
   +t^6 b6 b6Cmt
   +t^6 c6 c6Cmt
   +t^6 d6 d6Cmt
   +t^6 e6 e6Cmt
   +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);
y=Expand[Normal[Series[y,{t,0,DEGREE}]]];

w=( t   newa1 X 
   +t   newb1 Y
   +t^2 newa2 a2Cmt
   +t^3 newa3 a3Cmt
   +t^3 newb3 b3Cmt
   +t^4 newa4 a4Cmt
   +t^4 newb4 b4Cmt
   +t^5 newa5 a5Cmt
   +t^5 newb5 b5Cmt
   +t^5 newc5 c5Cmt
   +t^5 newd5 d5Cmt
   +t^6 newa6 a6Cmt
   +t^6 newb6 b6Cmt
   +t^6 newc6 c6Cmt
   +t^6 newd6 d6Cmt
   +t^6 newe6 e6Cmt
   +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);
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)"];
termxy=MmPoly[termx,termy];

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