(self, sym, a, b)
return mul * ret_fun
Evaluates the function along the sym in a given interval ab
Evaluates the function along the sym in a given interval ab
Evaluates the function along the sym in a given interval ab
def _eval_interval(self, sym, a, b):
        """Evaluates the function along the sym in a given interval ab"""
        # FIXME: Currently complex intervals are not supported.  A possible
        # replacement algorithm, discussed in issue 5227, can be found in the
        # following papers;
        #     http://portal.acm.org/citation.cfm?id=281649
        #     http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.70.4127&rep=rep1&type=pdf

        if a is None or b is None:
            # In this case, it is just simple substitution
            return piecewise_fold(
                super(Piecewise, self)._eval_interval(sym, a, b))

        mul = 1
        if (a == b) == True:
            return S.Zero
        elif (a > b) == True:
            a, b, mul = b, a, -1
        elif (a <= b) != True:
            newargs = []
            for e, c in self.args:
                intervals = self._sort_expr_cond(
                    sym, S.NegativeInfinity, S.Infinity, c)
                values = []
                for lower, upper, expr in intervals:
                    if (a < lower) == True:
                        mid = lower
                        rep = b
                        val = e._eval_interval(sym, mid, b)
                        val += self._eval_interval(sym, a, mid)
                    elif (a > upper) == True:
                        mid = upper
                        rep = b
                        val = e._eval_interval(sym, mid, b)
                        val += self._eval_interval(sym, a, mid)
                    elif (a >= lower) == True and (a <= upper) == True:
                        rep = b
                        val = e._eval_interval(sym, a, b)
                    elif (b < lower) == True:
                        mid = lower
                        rep = a
                        val = e._eval_interval(sym, a, mid)
                        val += self._eval_interval(sym, mid, b)
                    elif (b > upper) == True:
                        mid = upper
                        rep = a
                        val = e._eval_interval(sym, a, mid)
                        val += self._eval_interval(sym, mid, b)
                    elif ((b >= lower) == True) and ((b <= upper) == True):
                        rep = a
                        val = e._eval_interval(sym, a, b)
                    else:
                        raise NotImplementedError(
                            """The evaluation of a Piecewise interval when both the lower
                            and the upper limit are symbolic is not yet implemented.""")
                    values.append(val)
                if len(set(values)) == 1:
                    try:
                        c = c.subs(sym, rep)
                    except AttributeError:
                        pass
                    e = values[0]
                    newargs.append((e, c))
                else:
                    for i in range(len(values)):
                        newargs.append((values[i], (c == True and i == len(values) - 1) or
                            And(rep >= intervals[i][0], rep <= intervals[i][1])))
            return self.func(*newargs)

        # Determine what intervals the expr,cond pairs affect.
        int_expr = self._sort_expr_cond(sym, a, b)

        # Finally run through the intervals and sum the evaluation.
        ret_fun = 0
        for int_a, int_b, expr in int_expr:
            if isinstance(expr, Piecewise):
                # If we still have a Piecewise by now, _sort_expr_cond would
                # already have determined that its conditions are independent
                # of the integration variable, thus we just use substitution.
                ret_fun += piecewise_fold(
                    super(Piecewise, expr)._eval_interval(sym, Max(a, int_a), Min(b, int_b)))
            else:
                ret_fun += expr._eval_interval(sym, Max(a, int_a), Min(b, int_b))
        return mul * ret_fun
def _eval_interval ( self , sym , a , b ) : # FIXME: Currently complex intervals are not supported.  A possible # replacement algorithm, discussed in issue 5227, can be found in the # following papers; #     http://portal.acm.org/citation.cfm?id=281649 #     http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.70.4127&rep=rep1&type=pdf if a is None or b is None : # In this case, it is just simple substitution return piecewise_fold ( super ( Piecewise , self ) . _eval_interval ( sym , a , b ) ) mul = 1 if ( a == b ) == True : return S . Zero elif ( a > b ) == True : a , b , mul = b , a , - 1 elif ( a <= b ) != True : newargs = [ ] for e , c in self . args : intervals = self . _sort_expr_cond ( sym , S . NegativeInfinity , S . Infinity , c ) values = [ ] for lower , upper , expr in intervals : if ( a < lower ) == True : mid = lower rep = b val = e . _eval_interval ( sym , mid , b ) val += self . _eval_interval ( sym , a , mid ) elif ( a > upper ) == True : mid = upper rep = b val = e . _eval_interval ( sym , mid , b ) val += self . _eval_interval ( sym , a , mid ) elif ( a >= lower ) == True and ( a <= upper ) == True : rep = b val = e . _eval_interval ( sym , a , b ) elif ( b < lower ) == True : mid = lower rep = a val = e . _eval_interval ( sym , a , mid ) val += self . _eval_interval ( sym , mid , b ) elif ( b > upper ) == True : mid = upper rep = a val = e . _eval_interval ( sym , a , mid ) val += self . _eval_interval ( sym , mid , b ) elif ( ( b >= lower ) == True ) and ( ( b <= upper ) == True ) : rep = a val = e . _eval_interval ( sym , a , b ) else : raise NotImplementedError ( """The evaluation of a Piecewise interval when both the lower
                            and the upper limit are symbolic is not yet implemented.""" ) values . append ( val ) if len ( set ( values ) ) == 1 : try : c = c . subs ( sym , rep ) except AttributeError : pass e = values [ 0 ] newargs . append ( ( e , c ) ) else : for i in range ( len ( values ) ) : newargs . append ( ( values [ i ] , ( c == True and i == len ( values ) - 1 ) or And ( rep >= intervals [ i ] [ 0 ] , rep <= intervals [ i ] [ 1 ] ) ) ) return self . func ( * newargs ) # Determine what intervals the expr,cond pairs affect. int_expr = self . _sort_expr_cond ( sym , a , b ) # Finally run through the intervals and sum the evaluation. ret_fun = 0 for int_a , int_b , expr in int_expr : if isinstance ( expr , Piecewise ) : # If we still have a Piecewise by now, _sort_expr_cond would # already have determined that its conditions are independent # of the integration variable, thus we just use substitution. ret_fun += piecewise_fold ( super ( Piecewise , expr ) . _eval_interval ( sym , Max ( a , int_a ) , Min ( b , int_b ) ) ) else : ret_fun += expr . _eval_interval ( sym , Max ( a , int_a ) , Min ( b , int_b ) ) return mul * ret_fun