def rs_compose_add(p1, p2):
 R = p1.ring
 x = R.gens[0]
 prec = ((p1.degree() * p2.degree()) + 1)
 np1 = rs_newton(p1, x, prec)
 np1e = rs_hadamard_exp(np1)
 np2 = rs_newton(p2, x, prec)
 np2e = rs_hadamard_exp(np2)
 np3e = rs_mul(np1e, np2e, x, prec)
 np3 = rs_hadamard_exp(np3e, True)
 np3a = ((np3[(0,)] - np3) / x)
 q = rs_integrate(np3a, x)
 q = rs_exp(q, x, prec)
 q = _invert_monoms(q)
 q = q.primitive()[1]
 dp = ((p1.degree() * p2.degree()) - q.degree())
 if dp:
  q = (q * (x ** dp))
 return q

def rs_compose_add ( p1 , p2 ) : R = p1 . ring x = R . gens [ 0 ] prec = ( ( p1 . degree ( ) * p2 . degree ( ) ) + 1 ) np1 = rs_newton ( p1 , x , prec ) np1e = rs_hadamard_exp ( np1 ) np2 = rs_newton ( p2 , x , prec ) np2e = rs_hadamard_exp ( np2 ) np3e = rs_mul ( np1e , np2e , x , prec ) np3 = rs_hadamard_exp ( np3e , True ) np3a = ( ( np3 [ ( 0 , ) ] - np3 ) / x ) q = rs_integrate ( np3a , x ) q = rs_exp ( q , x , prec ) q = _invert_monoms ( q ) q = q . primitive ( ) [ 1 ] dp = ( ( p1 . degree ( ) * p2 . degree ( ) ) - q . degree ( ) ) if dp : q = ( q * ( x ** dp ) ) return q
compute the composed sum prod(p2 for beta root of p1) examples .