code: def rationalize(x, maxcoeff=10000):
      """
      Helps identifying a rational number from a float (or mpmath.mpf) value by
      using a continued fraction. The algorithm stops as soon as a large partial
      quotient is detected (greater than 10000 by default).
  
      Examples
      ========
  
      >>> from sympy.concrete.guess import rationalize
      >>> from mpmath import cos, pi
      >>> rationalize(cos(pi/3))
      1/2
  
      >>> from mpmath import mpf
      >>> rationalize(mpf("0.333333333333333"))
      1/3
  
      While the function is rather intended to help 'identifying' rational
      values, it may be used in some cases for approximating real numbers.
      (Though other functions may be more relevant in that case.)
  
      >>> rationalize(pi, maxcoeff = 250)
      355/113
  
      See Also
      ========
  
      Several other methods can approximate a real number as a rational, like:
  
        * fractions.Fraction.from_decimal
        * fractions.Fraction.from_float
        * mpmath.identify
        * mpmath.pslq by using the following syntax: mpmath.pslq([x, 1])
        * mpmath.findpoly by using the following syntax: mpmath.findpoly(x, 1)
        * sympy.simplify.nsimplify (which is a more general function)
  
      The main difference between the current function and all these variants is
      that control focuses on magnitude of partial quotients here rather than on
      global precision of the approximation. If the real is "known to be" a
      rational number, the current function should be able to detect it correctly
      with the default settings even when denominator is great (unless its
      expansion contains unusually big partial quotients) which may occur
      when studying sequences of increasing numbers. If the user cares more
      on getting simple fractions, other methods may be more convenient.
  
      """
      p0, p1 = 0, 1
      q0, q1 = 1, 0
      a = floor(x)
      while a < maxcoeff or q1 == 0:
          p = a * p1 + p0
          q = a * q1 + q0
          p0, p1 = p1, p
          q0, q1 = q1, q
          if x == a:
              break
          x = 1 / (x - a)
          a = floor(x)
      return sympify(p) / q
  
file_path: sympy/sympy/concrete/guess.py
imports: from sympy.concrete.products import Product, product
  from sympy.core import Function, S
  from sympy.core.add import Add
  from sympy.core.numbers import Integer, Rational
  from sympy.core.symbol import Symbol, symbols
  from sympy.core.sympify import sympify
  from sympy.functions.elementary.exponential import exp
  from sympy.functions.elementary.integers import floor
  from sympy.integrals.integrals import integrate
  from sympy.polys.polyfuncs import rational_interpolate
  from sympy.polys.polytools import lcm
  from sympy.simplify.radsimp import denom
  from sympy.utilities import public
label_desc: Use image node_id 3 for calling a global function with example usage: rationalize(x, maxcoeff) and returns: unknown