class_docstr: Efficient representation of ``f_1*f_2*...*f_n``.
class_docstr_tok: ["Efficient","representation","of","``","f_1","*","f_2","*","...","*","f_n","``","."]
docstr: Return ``self`` and ``other`` with ``gcd`` removed from each.
  This is optimized for the case when there are many factors in common.
  
  Examples
  ========
  
  >>> from sympy.core.exprtools import Factors
  >>> from sympy.abc import x, y, z
  >>> from sympy import S
  
  >>> a = Factors((x*y**2).as_powers_dict())
  >>> a.div(a)
  (Factors({}), Factors({}))
  >>> a.div(x*z)
  (Factors({y: 2}), Factors({z: 1}))
  
  The ``/`` operator only gives ``quo``:
  
  >>> a/x
  Factors({y: 2})
  
  Factors treats its factors as though they are all in the numerator, so
  if you violate this assumption the results will be correct but will
  not strictly correspond to the numerator and denominator of the ratio:
  
  >>> a.div(x/z)
  (Factors({y: 2}), Factors({z: -1}))
  
  Factors is also naive about bases: it does not attempt any denesting
  of Rational-base terms, for example the following does not become
  2**(2*x)/2.
  
  >>> Factors(2**(2*x + 2)).div(S(8))
  (Factors({2: 2*x + 2}), Factors({8: 1}))
  
  factor_terms can clean up such Rational-bases powers:
  
  >>> from sympy import factor_terms
  >>> n, d = Factors(2**(2*x + 2)).div(S(8))
  >>> n.as_expr()/d.as_expr()
  2**(2*x + 2)/8
  >>> factor_terms(_)
  2**(2*x)/2
docstr_tok: ["Return","``","self","``","and","``","other","``","with","``","gcd","``","removed","from","each",".","This","is","optimized","for","the","case","when","there","are","many","factors","in","common",".","Examples","========",">",">",">","from","sympy.core.exprtools","import","Factors",">",">",">","from","sympy.abc","import","x",",","y",",","z",">",">",">","from","sympy","import","S",">",">",">","a","=","Factors","(","(","x","*","y","*","*","2",")",".as_powers_dict","(",")",")",">",">",">","a.div","(","a",")","(","Factors","(","{","}",")",",","Factors","(","{","}",")",")",">",">",">","a.div","(","x","*","z",")","(","Factors","(","{","y",":","2","}",")",",","Factors","(","{","z",":","1","}",")",")","The","``","\/","``","operator","only","gives","``","quo","``",":",">",">",">","a\/x","Factors","(","{","y",":","2","}",")","Factors","treats","its","factors","as","though","they","are","all","in","the","numerator",",","so","if","you","violate","this","assumption","the","results","will","be","correct","but","will","not","strictly","correspond","to","the","numerator","and","denominator","of","the","ratio",":",">",">",">","a.div","(","x\/z",")","(","Factors","(","{","y",":","2","}",")",",","Factors","(","{","z",":","-1","}",")",")","Factors","is","also","naive","about","bases",":","it","does","not","attempt","any","denesting","of","Rational-base","terms",",","for","example","the","following","does","not","become","2","*","*","(","2","*","x",")","\/2",".",">",">",">","Factors","(","2","*","*","(","2","*","x","+","2",")",")",".div","(","S","(","8",")",")","(","Factors","(","{","2",":","2","*","x","+","2","}",")",",","Factors","(","{","8",":","1","}",")",")","factor_terms","can","clean","up","such","Rational-bases","powers",":",">",">",">","from","sympy","import","factor_terms",">",">",">","n",",","d","=","Factors","(","2","*","*","(","2","*","x","+","2",")",")",".div","(","S","(","8",")",")",">",">",">","n.as_expr","(",")","\/d.as_expr","(",")","2","*","*","(","2","*","x","+","2",")","\/8",">",">",">","factor_terms","(","_",")","2","*","*","(","2","*","x",")","\/2"]
code: def div(self, other):  # Factors
      """Return ``self`` and ``other`` with ``gcd`` removed from each.
      This is optimized for the case when there are many factors in common.
  
      Examples
      ========
  
      >>> from sympy.core.exprtools import Factors
      >>> from sympy.abc import x, y, z
      >>> from sympy import S
  
      >>> a = Factors((x*y**2).as_powers_dict())
      >>> a.div(a)
      (Factors({}), Factors({}))
      >>> a.div(x*z)
      (Factors({y: 2}), Factors({z: 1}))
  
      The ``/`` operator only gives ``quo``:
  
      >>> a/x
      Factors({y: 2})
  
      Factors treats its factors as though they are all in the numerator, so
      if you violate this assumption the results will be correct but will
      not strictly correspond to the numerator and denominator of the ratio:
  
      >>> a.div(x/z)
      (Factors({y: 2}), Factors({z: -1}))
  
      Factors is also naive about bases: it does not attempt any denesting
      of Rational-base terms, for example the following does not become
      2**(2*x)/2.
  
      >>> Factors(2**(2*x + 2)).div(S(8))
      (Factors({2: 2*x + 2}), Factors({8: 1}))
  
      factor_terms can clean up such Rational-bases powers:
  
      >>> from sympy import factor_terms
      >>> n, d = Factors(2**(2*x + 2)).div(S(8))
      >>> n.as_expr()/d.as_expr()
      2**(2*x + 2)/8
      >>> factor_terms(_)
      2**(2*x)/2
  
      """
      quo, rem = dict(self.factors), {}
  
      if not isinstance(other, Factors):
          other = Factors(other)
          if other.is_zero:
              raise ZeroDivisionError
          if self.is_zero:
              return (Factors(S.Zero), Factors())
  
      for factor, exp in other.factors.items():
          if factor in quo:
              d = quo[factor] - exp
              if _isnumber(d):
                  if d <= 0:
                      del quo[factor]
  
                  if d >= 0:
                      if d:
                          quo[factor] = d
  
                      continue
  
                  exp = -d
  
              else:
                  r = quo[factor].extract_additively(exp)
                  if r is not None:
                      if r:
                          quo[factor] = r
                      else:  # should be handled already
                          del quo[factor]
                  else:
                      other_exp = exp
                      sc, sa = quo[factor].as_coeff_Add()
                      if sc:
                          oc, oa = other_exp.as_coeff_Add()
                          diff = sc - oc
                          if diff > 0:
                              quo[factor] -= oc
                              other_exp = oa
                          elif diff < 0:
                              quo[factor] -= sc
                              other_exp = oa - diff
                          else:
                              quo[factor] = sa
                              other_exp = oa
                      if other_exp:
                          rem[factor] = other_exp
                      else:
                          assert factor not in rem
                  continue
  
          rem[factor] = exp
  
      return Factors(quo), Factors(rem)
  
imports: from .add import Add
  from .mul import Mul, _keep_coeff
  from .power import Pow
  from .basic import Basic
  from .expr import Expr
  from .function import expand_power_exp
  from .sympify import sympify
  from .numbers import Rational, Integer, Number, I, equal_valued
  from .singleton import S
  from .sorting import default_sort_key, ordered
  from .symbol import Dummy
  from .traversal import preorder_traversal
  from .coreerrors import NonCommutativeExpression
  from .containers import Tuple, Dict
  from sympy.external.gmpy import SYMPY_INTS
  from sympy.utilities.iterables import common_prefix, common_suffix, variations, iterable, is_sequence
  from collections import defaultdict
  from typing import Tuple
label_desc: Use image node_id 9 for calling the Factors obj's underlying member method code with example usage: obj.div(other) and returns: Factors,  Factors, Factors,  Factors