%mathpiper,def="Quotient"

/* Integer divisions */
0 # Quotient(n_IsInteger,m_IsInteger) <-- QuotientN(n,m);
1 # Quotient(0  ,_m) <-- 0;
2 # Quotient(n_IsRationalOrNumber,m_IsRationalOrNumber) <--
[
  Local(n1,n2,m1,m2,sgn1,sgn2);
  n1:=Numerator(n);
  n2:=Denominator(n);
  m1:=Numerator(m);
  m2:=Denominator(m);
  sgn1 := Sign(n1*m2);
  sgn2 := Sign(m1*n2);
  sgn1*sgn2*Floor(DivideN(sgn1*n1*m2,sgn2*m1*n2));
];
30 # Quotient(n_CanBeUni,m_CanBeUni)_(Length(VarList(n*m))=1) <--
[

  Local(vars,nl,ml);
  vars:=VarList(n*m);
  nl := MakeUni(n,vars);
  ml := MakeUni(m,vars);
  NormalForm(Quotient(nl,ml));
];


//Note:tk:moved here from univariate.rep.
0 # Quotient(n_IsUniVar,m_IsUniVar)_(Degree(n) < Degree(m)) <-- 0;
1 # Quotient(n_IsUniVar,m_IsUniVar)_
    (n[1] = m[1] And Degree(n) >= Degree(m)) <--
[
    UniVariate(n[1],0,
               UniDivide(Concat(ZeroVector(n[2]),n[3]),
                         Concat(ZeroVector(m[2]),m[3]))[1]);
];

%/mathpiper


%mathpiper_docs,name="Quotient",categories="User Functions;Numbers (Operations)"
*CMD Quotient --- Determine quotient of two mathematical objects

*STD
*CALL
	Quotient(x,y)

*PARMS

{x}, {y} -- integers or univariate polynomials

*DESC

{Quotient} performs integer division. {Quotient} is also defined for polynomials.

If {Quotient(x,y)} returns "a" and {Modulo(x,y)} equals "b", then these numbers satisfy $x =a*y + b$ and $0 <= b < y$.

*E.G.

In> Quotient(5,3)
Result: 1;
In> Modulo(5,3)
Result: 2;

*SEE Gcd, Lcm, Modulo
%/mathpiper_docs