def _complex_expand_series(context, builder, ty, initial, x, coefs):
 assert (ty in types.complex_domain)
 binary_sig = typing.signature(*([ty] * 3))
 accum = context.make_complex(builder, ty, value=initial)
 ONE = context.get_constant(ty.underlying_float, 1.0)
 for coef in reversed(coefs):
  constant = context.get_constant(ty.underlying_float, coef)
  value = numbers.complex_mul_impl(context, builder, binary_sig, [x, accum._getvalue()])
  accum._setvalue(value)
  accum.real = builder.fadd(ONE, builder.fmul(accum.real, constant))
  accum.imag = builder.fmul(accum.imag, constant)
 return accum._getvalue()

def _complex_expand_series ( context , builder , ty , initial , x , coefs ) : assert ( ty in types . complex_domain ) binary_sig = typing . signature ( * ( [ ty ] * 3 ) ) accum = context . make_complex ( builder , ty , value = initial ) ONE = context . get_constant ( ty . underlying_float , 1.0 ) for coef in reversed ( coefs ) : constant = context . get_constant ( ty . underlying_float , coef ) value = numbers . complex_mul_impl ( context , builder , binary_sig , [ x , accum . _getvalue ( ) ] ) accum . _setvalue ( value ) accum . real = builder . fadd ( ONE , builder . fmul ( accum . real , constant ) ) accum . imag = builder . fmul ( accum . imag , constant ) return accum . _getvalue ( )
this is used to implement approximations using series that are quite common in numpys source code to improve precision when the magnitude of the arguments is small .