def _deriv(UK, deriv):
    """Real deriv is to :math:`t`, complex deriv is to :math:`\ln t`"""
    if deriv == 0:
        return UK

    if isinstance(deriv, complex):
        def UKderiv(z):
            return (-z) ** deriv.imag * UK(z)
        return UKderiv

    def UKderiv(z):
        poly = arange(deriv) + 1
        poly = poly - z if ndim(z) == 0 else poly - z.reshape(-1, 1)
        poly = poly.prod(axis=-1)
        return poly * UK(z - deriv)
    return UKderiv
Real deriv is to :math:`t`, complex deriv is to :math:`\ln t`