def rs_atanh(p, x, prec):
 if rs_is_puiseux(p, x):
  return rs_puiseux(rs_atanh, p, x, prec)
 R = p.ring
 const = 0
 if _has_constant_term(p, x):
  zm = R.zero_monom
  c = p[zm]
  if (R.domain is EX):
   c_expr = c.as_expr()
   const = atanh(c_expr)
  elif isinstance(c, PolyElement):
   try:
    c_expr = c.as_expr()
    const = R(atanh(c_expr))
   except ValueError:
    raise DomainError("The given series can't be expanded in this domain.")
  else:
   try:
    const = R(atanh(c))
   except ValueError:
    raise DomainError("The given series can't be expanded in this domain.")
 dp = rs_diff(p, x)
 p1 = ((- rs_square(p, x, prec)) + 1)
 p1 = rs_series_inversion(p1, x, (prec - 1))
 p1 = rs_mul(dp, p1, x, (prec - 1))
 return (rs_integrate(p1, x) + const)

def rs_atanh ( p , x , prec ) : if rs_is_puiseux ( p , x ) : return rs_puiseux ( rs_atanh , p , x , prec ) R = p . ring const = 0 if _has_constant_term ( p , x ) : zm = R . zero_monom c = p [ zm ] if ( R . domain is EX ) : c_expr = c . as_expr ( ) const = atanh ( c_expr ) elif isinstance ( c , PolyElement ) : try : c_expr = c . as_expr ( ) const = R ( atanh ( c_expr ) ) except ValueError : raise DomainError ( "The given series can't be expanded in this domain." ) else : try : const = R ( atanh ( c ) ) except ValueError : raise DomainError ( "The given series can't be expanded in this domain." ) dp = rs_diff ( p , x ) p1 = ( ( - rs_square ( p , x , prec ) ) + 1 ) p1 = rs_series_inversion ( p1 , x , ( prec - 1 ) ) p1 = rs_mul ( dp , p1 , x , ( prec - 1 ) ) return ( rs_integrate ( p1 , x ) + const )
hyperbolic arctangent of a series return the series expansion of the atanh of p .