def _tanh(p, x, prec):
 R = p.ring
 p1 = R(0)
 for precx in _giant_steps(prec):
  tmp = (p - rs_atanh(p1, x, precx))
  tmp = rs_mul(tmp, (1 - rs_square(p1, x, prec)), x, precx)
  p1 += tmp
 return p1

def _tanh ( p , x , prec ) : R = p . ring p1 = R ( 0 ) for precx in _giant_steps ( prec ) : tmp = ( p - rs_atanh ( p1 , x , precx ) ) tmp = rs_mul ( tmp , ( 1 - rs_square ( p1 , x , prec ) ) , x , precx ) p1 += tmp return p1
helper function of rs_tanh return the series expansion of tanh of a univariate series using newtons method .