Ticket #10841: trac_10841_fix_piecewise_integrals_of_zero.patch

File trac_10841_fix_piecewise_integrals_of_zero.patch, 1.4 KB (added by D.S. McNeil, 12 years ago)
  • sage/functions/piecewise.py

    # HG changeset patch
    # User D. S. McNeil
    # Date 1298536689 -28800
    # Node ID d3bb8c30cfc0629c2416bf7b32282d8e8e39f96d
    # Parent  8438b7c20d79c02a2ece3e1c3f7224a772ff8f07
    Trac 10841: fix piecewise integrals involving zero
    
    diff -r 8438b7c20d79 -r d3bb8c30cfc0 sage/functions/piecewise.py
    a b  
    786786            sage: f.integral()
    787787            Piecewise defined function with 1 parts, [[(0, 5), x |--> sin(x)]]
    788788
     789
     790        TESTS::
     791
     792        Verify that piecewise integrals of zero work (trac #10841)::
     793
     794            sage: f0(x) = 0
     795            sage: f = Piecewise([[(0,1),f0]])
     796            sage: f.integral(x,0,1)
     797            0
     798            sage: f = Piecewise([[(0,1), 0]])
     799            sage: f.integral(x,0,1)
     800            0
     801            sage: f = Piecewise([[(0,1), SR(0)]])
     802            sage: f.integral(x,0,1)
     803            0
     804
    789805        """
    790806        if a != None and b != None:
    791807            F = self.integral(x)
     
    830846                forget(start < x)
    831847                if definite or end != infinity:
    832848                    area += fun.integral(x, start, end)
    833             new_pieces.append([(start, end), fun_integrated.function(x)])
     849            new_pieces.append([(start, end), SR(fun_integrated).function(x)])
    834850
    835851        if definite:
    836852            return SR(area)