code: def mpf_psi0(x, prec, rnd=round_fast):
      """
      Computation of the digamma function (psi function of order 0)
      of a real argument.
      """
      sign, man, exp, bc = x
      wp = prec + 10
      if not man:
          if x == finf:
              return x
          if x == fninf or x == fnan:
              return fnan
      if x == fzero or (exp >= 0 and sign):
          raise ValueError("polygamma pole")
      # Near 0 -- fixed-point arithmetic becomes bad
      if exp + bc < -5:
          v = mpf_psi0(mpf_add(x, fone, prec, rnd), prec, rnd)
          return mpf_sub(v, mpf_div(fone, x, wp, rnd), prec, rnd)
      # Reflection formula
      if sign and exp + bc > 3:
          c, s = mpf_cos_sin_pi(x, wp)
          q = mpf_mul(mpf_div(c, s, wp), mpf_pi(wp), wp)
          p = mpf_psi0(mpf_sub(fone, x, wp), wp)
          return mpf_sub(p, q, prec, rnd)
      # The logarithmic term is accurate enough
      if (not sign) and bc + exp > wp:
          return mpf_log(mpf_sub(x, fone, wp), prec, rnd)
      # Initial recurrence to obtain a large enough x
      m = to_int(x)
      n = int(0.11 * wp) + 2
      s = MPZ_ZERO
      x = to_fixed(x, wp)
      one = MPZ_ONE << wp
      if m < n:
          for k in xrange(m, n):
              s -= (one << wp) // x
              x += one
      x -= one
      # Logarithmic term
      s += to_fixed(mpf_log(from_man_exp(x, -wp, wp), wp), wp)
      # Endpoint term in Euler-Maclaurin expansion
      s += (one << wp) // (2 * x)
      # Euler-Maclaurin remainder sum
      x2 = (x * x) >> wp
      t = one
      prev = 0
      k = 1
      while 1:
          t = (t * x2) >> wp
          bsign, bman, bexp, bbc = mpf_bernoulli(2 * k, wp)
          offset = bexp + 2 * wp
          if offset >= 0:
              term = (bman << offset) // (t * (2 * k))
          else:
              term = (bman >> (-offset)) // (t * (2 * k))
          if k & 1:
              s -= term
          else:
              s += term
          if k > 2 and term >= prev:
              break
          prev = term
          k += 1
      return from_man_exp(s, -wp, wp, rnd)
  
imports: import math
  import sys
  from .backend import xrange
  from .backend import MPZ, MPZ_ZERO, MPZ_ONE, MPZ_THREE, gmpy
  from .libintmath import list_primes, ifac, ifac2, moebius
  from .libmpf import round_floor, round_ceiling, round_down, round_up, round_nearest, round_fast, lshift, sqrt_fixed, isqrt_fast, fzero, fone, fnone, fhalf, ftwo, finf, fninf, fnan, from_int, to_int, to_fixed, from_man_exp, from_rational, mpf_pos, mpf_neg, mpf_abs, mpf_add, mpf_sub, mpf_mul, mpf_mul_int, mpf_div, mpf_sqrt, mpf_pow_int, mpf_rdiv_int, mpf_perturb, mpf_le, mpf_lt, mpf_gt, mpf_shift, negative_rnd, reciprocal_rnd, bitcount, to_float, mpf_floor, mpf_sign, ComplexResult
  from .libelefun import constant_memo, def_mpf_constant, mpf_pi, pi_fixed, ln2_fixed, log_int_fixed, mpf_ln2, mpf_exp, mpf_log, mpf_pow, mpf_cosh, mpf_cos_sin, mpf_cosh_sinh, mpf_cos_sin_pi, mpf_cos_pi, mpf_sin_pi, ln_sqrt2pi_fixed, mpf_ln_sqrt2pi, sqrtpi_fixed, mpf_sqrtpi, cos_sin_fixed, exp_fixed
  from .libmpc import mpc_zero, mpc_one, mpc_half, mpc_two, mpc_abs, mpc_shift, mpc_pos, mpc_neg, mpc_add, mpc_sub, mpc_mul, mpc_div, mpc_add_mpf, mpc_mul_mpf, mpc_div_mpf, mpc_mpf_div, mpc_mul_int, mpc_pow_int, mpc_log, mpc_exp, mpc_pow, mpc_cos_pi, mpc_sin_pi, mpc_reciprocal, mpc_square, mpc_sub_mpf
label_desc: Use image node_id 14 for calling a global function with example usage: mpf_psi0(x, prec, rnd) and returns: from_man_exp, mpf_sub, mpf_sub, mpf_log, x, fnan