%mathpiper,def="GcdReduce"

/* Reduce rational function by dividing gcd away */
GcdReduce(_f,_var)<--
[
  Local(rat,gcd);
  rat:=RationalForm(f,var);
  gcd:=Gcd(rat[1],rat[2]);
/*  gcd:=gcd*Gcd(Content(rat[1]),Content(rat[2]));*/

  Local(numer,denom,lc);
  numer:=Quotient(rat[1],gcd);
  denom:=Quotient(rat[2],gcd);
  lc:=LeadingCoef(numer,var);
  numer:=numer/lc;
  denom:=denom/lc;
  Expand(numer)/Expand(denom);
];

%/mathpiper