code: def res_z(f, g, x):
      """
      The input polynomials f, g are in Z[x] or in Q[x].
  
      The output is the resultant of f, g computed recursively
      by polynomial divisions in Z[x], using the function prem().
      See Cohen's book p. 283.
  
      References:
      ===========
      1. J. S. Cohen: Computer Algebra and Symbolic Computation
       - Mathematical Methods. A. K. Peters, 2003.
      """
      m = degree(f, x)
      n = degree(g, x)
      if m < n:
          return (-1) ** (m * n) * res_z(g, f, x)
      elif n == 0:  # g is a constant
          return g**m
      else:
          r = prem(f, g, x)
          if r == 0:
              return 0
          else:
              delta = m - n + 1
              w = (-1) ** (m * n) * res_z(g, r, x)
              s = degree(r, x)
              l = LC(g, x)
              k = delta * n - m + s
              return quo(w, l**k, x)
  
imports: from sympy.concrete.summations import summation
  from sympy.core.function import expand
  from sympy.core.numbers import nan
  from sympy.core.singleton import S
  from sympy.core.symbol import Dummy
  from sympy.functions.elementary.complexes import Abs, sign
  from sympy.functions.elementary.integers import floor
  from sympy.matrices.dense import eye, Matrix, zeros
  from sympy.printing.pretty.pretty import pretty_print
  from sympy.simplify.simplify import simplify
  from sympy.polys.domains import QQ
  from sympy.polys.polytools import degree, LC, Poly, pquo, quo, prem, rem
  from sympy.polys.polyerrors import PolynomialError
label_desc: Use image node_id 7 for calling a global function with example usage: res_z(f, g, x) and returns: unknown, unknown, int, quo