'Derivative of 1D Legendre polynomial'

def _legendderiv1d(self, x, deg):

    x = np.array(x, dtype=np.float, copy=False, ndmin=1)
    d = np.empty((((deg + 1),) + x.shape), dtype=x.dtype)
    d[0] = ((x * 0) + 1)
    if (deg > 0):
        d[1] = x
        for i in range(2, (deg + 1)):
            d[i] = ((((d[(i - 1)] * x) * ((2 * i) - 1)) - (d[(i - 2)] * (i - 1))) / i)
    return np.rollaxis(d, 0, d.ndim)
