'Construct a new piecewise polynomial representing the antiderivative.
Parameters
nu : int, optional
Order of antiderivative to evaluate. Default is 1, i.e. compute
the first integral. If negative, the derivative is returned.
Returns
bp : BPoly
Piecewise polynomial of order k + nu representing the
antiderivative of this polynomial.
Notes
If antiderivative is computed and ``self.extrapolate=\'periodic\'``,
it will be set to False for the returned instance. This is done because
the antiderivative is no longer periodic and its correct evaluation
outside of the initially given x interval is difficult.'

def antiderivative(self, nu=1):

    if (nu <= 0):
        return self.derivative((- nu))
    if (nu > 1):
        bp = self
        for k in range(nu):
            bp = bp.antiderivative()
        return bp
    (c, x) = (self.c, self.x)
    k = c.shape[0]
    c2 = np.zeros((((k + 1),) + c.shape[1:]), dtype=c.dtype)
    c2[1:, ...] = (np.cumsum(c, axis=0) / k)
    delta = (x[1:] - x[:(-1)])
    c2 *= delta[((None, slice(None)) + ((None,) * (c.ndim - 2)))]
    c2[:, 1:] += np.cumsum(c2[k, :], axis=0)[:(-1)]
    if (self.extrapolate == 'periodic'):
        extrapolate = False
    else:
        extrapolate = self.extrapolate
    return self.construct_fast(c2, x, extrapolate, axis=self.axis)
