/**  Polynomial Division **/
/*A: K McIsaac*/
/*S: University of Western Australia, Nedlands 6009, Australia*/
/*D: October, 1985 */
/*K: Polynomial, Division, Mixed Fraction, Remainder, Quotient,Fac,Factorise */
/*U: Fri 13th March 1987 by John Gottschalk */

/*: Pd[$poly,($form)] 
	Mixed fraction representation for rational polynomial $poly 
	with "base" $form. The default for $form is a symbol common to 
	the numerator and denominator of $poly. */
Pd_:Tier
Pd[$n/$d,$b] :: (Lcl[%pqr] ; \
		 %pqr : Pqr[Ex[$n],$d,$b] ; Ex[%pqr[1]] + Ex[%pqr[2]]/$d)
Pd[$n/$d] :: (Lcl[%var];%var : Inter[Cont[$n],Cont[$d]];Pd[$n/$d,Rel[%var[1]]])

/*: Sep[$expr,$fac]
	finds the mixed fraction representation for $expr/$fac and multiplies
	it by $fac. If $fac is a factor of $expr the result is equivalent
	to factoring $fac out of $expr. */
Sep_:Tier
Sep[$expr,$fac] :: Pd[$expr/$fac] $fac

/*E:
SMP 1.5.0   (May 14 1986)
Fri Mar 13 16:30:53 1987

#I[1]::  <XPd

#I[2]::  (x^2-x-4)/(x-2)

		   2
	 -4 - x + x
#O[2]:   -----------
	   -2 + x

#I[3]::  Pd[%,x]

		   2
#O[3]:   1 + x - ------
		 -2 + x

#I[4]::  (x+y)^3

		3
#O[4]:   (x + y)

#I[5]::  Ex[%]

	     2      2      3    3
#O[5]:   3x y  + 3 x  y + x  + y

#I[6]::  Sep[%,x+y]

			  2    2
#O[6]:   (x + y) (2x y + x  + y )
*/
