code: def mpf_atanh(x, prec, rnd=round_fast):
      # atanh(x) = log((1+x)/(1-x))/2
      sign, man, exp, bc = x
      if (not man) and exp:
          if x in (fzero, fnan):
              return x
          raise ComplexResult("atanh(x) is real only for -1 <= x <= 1")
      mag = bc + exp
      if mag > 0:
          if mag == 1 and man == 1:
              return [finf, fninf][sign]
          raise ComplexResult("atanh(x) is real only for -1 <= x <= 1")
      wp = prec + 15
      if mag < -8:
          if mag < -wp:
              return mpf_perturb(x, sign, prec, rnd)
          wp += -mag
      a = mpf_add(x, fone, wp)
      b = mpf_sub(fone, x, wp)
      return mpf_shift(mpf_log(mpf_div(a, b, wp), prec, rnd), -1)
  
imports: import math
  from bisect import bisect
  from .backend import xrange
  from .backend import MPZ, MPZ_ZERO, MPZ_ONE, MPZ_TWO, MPZ_FIVE, BACKEND
  from .libmpf import round_floor, round_ceiling, round_down, round_up, round_nearest, round_fast, ComplexResult, bitcount, bctable, lshift, rshift, giant_steps, sqrt_fixed, from_int, to_int, from_man_exp, to_fixed, to_float, from_float, from_rational, normalize, fzero, fone, fnone, fhalf, finf, fninf, fnan, mpf_cmp, mpf_sign, mpf_abs, mpf_pos, mpf_neg, mpf_add, mpf_sub, mpf_mul, mpf_div, mpf_shift, mpf_rdiv_int, mpf_pow_int, mpf_sqrt, reciprocal_rnd, negative_rnd, mpf_perturb, isqrt_fast
  from .libintmath import ifib
label_desc: Use image node_id 38 for calling a global function with example usage: mpf_atanh(x, prec, rnd) and returns: mpf_shift, x, list, mpf_perturb