<s> from sympy . core . compatibility import range <EOL> from sympy import cos , DiracDelta , Heaviside , Function , pi , S , sin , symbols <EOL> from sympy . integrals . deltafunctions import change_mul , deltaintegrate <EOL> f = Function ( "<STR_LIT:f>" ) <EOL> x_1 , x_2 , x , y , z = symbols ( "<STR_LIT>" ) <EOL> def test_change_mul ( ) : <EOL> assert change_mul ( x , x ) == x <EOL> assert change_mul ( x * y , x ) == ( None , None ) <EOL> assert change_mul ( x * y * DiracDelta ( x ) , x ) == ( DiracDelta ( x ) , x * y ) <EOL> assert change_mul ( x * y * DiracDelta ( x ) * DiracDelta ( y ) , x ) == ( DiracDelta ( x ) , x * y * DiracDelta ( y ) ) <EOL> assert change_mul ( DiracDelta ( x ) ** <NUM_LIT:2> , x ) == ( DiracDelta ( x ) , DiracDelta ( x ) ) <EOL> assert change_mul ( y * DiracDelta ( x ) ** <NUM_LIT:2> , x ) == ( DiracDelta ( x ) , y * DiracDelta ( x ) ) <EOL> def test_deltaintegrate ( ) : <EOL> assert deltaintegrate ( x , x ) is None <EOL> assert deltaintegrate ( x + DiracDelta ( x ) , x ) is None <EOL> assert deltaintegrate ( DiracDelta ( x , <NUM_LIT:0> ) , x ) == Heaviside ( x ) <EOL> for n in range ( <NUM_LIT:10> ) : <EOL> assert deltaintegrate ( DiracDelta ( x , n + <NUM_LIT:1> ) , x ) == DiracDelta ( x , n ) <EOL> assert deltaintegrate ( DiracDelta ( x ) , x ) == Heaviside ( x ) <EOL> assert deltaintegrate ( DiracDelta ( - x ) , x ) == Heaviside ( x ) <EOL> assert deltaintegrate ( DiracDelta ( x - y ) , x ) == Heaviside ( x - y ) <EOL> assert deltaintegrate ( DiracDelta ( y - x ) , x ) == Heaviside ( x - y ) <EOL> assert deltaintegrate ( x * DiracDelta ( x ) , x ) == <NUM_LIT:0> <EOL> assert deltaintegrate ( ( x - y ) * DiracDelta ( x - y ) , x ) == <NUM_LIT:0> <EOL> assert deltaintegrate ( DiracDelta ( x ) ** <NUM_LIT:2> , x ) == DiracDelta ( <NUM_LIT:0> ) * Heaviside ( x ) <EOL> assert deltaintegrate ( y * DiracDelta ( x ) ** <NUM_LIT:2> , x ) == y * DiracDelta ( <NUM_LIT:0> ) * Heaviside ( x ) <EOL> assert deltaintegrate ( DiracDelta ( x , <NUM_LIT:1> ) ** <NUM_LIT:2> , x ) is None <EOL> assert deltaintegrate ( y * DiracDelta ( x , <NUM_LIT:1> ) ** <NUM_LIT:2> , x ) is None <EOL> assert deltaintegrate ( DiracDelta ( x ) * f ( x ) , x ) == f ( <NUM_LIT:0> ) * Heaviside ( x ) <EOL> assert deltaintegrate ( DiracDelta ( - x ) * f ( x ) , x ) == f ( <NUM_LIT:0> ) * Heaviside ( x ) <EOL> assert deltaintegrate ( DiracDelta ( x - <NUM_LIT:1> ) * f ( x ) , x ) == f ( <NUM_LIT:1> ) * Heaviside ( x - <NUM_LIT:1> ) <EOL> assert deltaintegrate ( DiracDelta ( <NUM_LIT:1> - x ) * f ( x ) , x ) == f ( <NUM_LIT:1> ) * Heaviside ( x - <NUM_LIT:1> ) <EOL> assert deltaintegrate ( DiracDelta ( x ** <NUM_LIT:2> + x - <NUM_LIT:2> ) , x ) == Heaviside ( x - <NUM_LIT:1> ) / <NUM_LIT:3> + Heaviside ( x + <NUM_LIT:2> ) / <NUM_LIT:3> <EOL> p = cos ( x ) * ( DiracDelta ( x ) + DiracDelta ( x ** <NUM_LIT:2> - <NUM_LIT:1> ) ) * sin ( x ) * ( x - pi ) <EOL> assert deltaintegrate ( p , x ) - ( - pi * ( cos ( <NUM_LIT:1> ) * Heaviside ( - <NUM_LIT:1> + x ) * sin ( <NUM_LIT:1> ) / <NUM_LIT:2> - cos ( <NUM_LIT:1> ) * Heaviside ( <NUM_LIT:1> + x ) * sin ( <NUM_LIT:1> ) / <NUM_LIT:2> ) + cos ( <NUM_LIT:1> ) * Heaviside ( <NUM_LIT:1> + x ) * sin ( <NUM_LIT:1> ) / <NUM_LIT:2> + cos ( <NUM_LIT:1> ) * Heaviside ( - <NUM_LIT:1> + x ) * sin ( <NUM_LIT:1> ) / <NUM_LIT:2> ) == <NUM_LIT:0> <EOL> p = x_2 * DiracDelta ( x - x_2 ) * DiracDelta ( x_2 - x_1 ) <EOL> assert deltaintegrate ( p , x_2 ) == x * DiracDelta ( x - x_1 ) * Heaviside ( x_2 - x ) <EOL> p = x * y ** <NUM_LIT:2> * z * DiracDelta ( y - x ) * DiracDelta ( y - z ) * DiracDelta ( x - z ) <EOL> assert deltaintegrate ( p , y ) == x ** <NUM_LIT:3> * z * DiracDelta ( x - z ) ** <NUM_LIT:2> * Heaviside ( y - x ) <EOL> assert deltaintegrate ( ( x + <NUM_LIT:1> ) * DiracDelta ( <NUM_LIT:2> * x ) , x ) == S ( <NUM_LIT:1> ) / <NUM_LIT:2> * Heaviside ( x ) <EOL> assert deltaintegrate ( ( x + <NUM_LIT:1> ) * DiracDelta ( <NUM_LIT:2> * x / <NUM_LIT:3> + <NUM_LIT:4> / S ( <NUM_LIT:9> ) ) , x ) == S ( <NUM_LIT:1> ) / <NUM_LIT:2> * Heaviside ( x + S ( <NUM_LIT:2> ) / <NUM_LIT:3> ) <EOL> a , b , c = symbols ( '<STR_LIT>' , commutative = False ) <EOL> assert deltaintegrate ( DiracDelta ( x - y ) * f ( x - b ) * f ( x - a ) , x ) == f ( y - b ) * f ( y - a ) * Heaviside ( x - y ) <EOL> p = f ( x - a ) * DiracDelta ( x - y ) * f ( x - c ) * f ( x - b ) <EOL> assert deltaintegrate ( p , x ) == f ( y - a ) * f ( y - c ) * f ( y - b ) * Heaviside ( x - y ) <EOL> p = DiracDelta ( x - z ) * f ( x - b ) * f ( x - a ) * DiracDelta ( x - y ) <EOL> assert deltaintegrate ( p , x ) == DiracDelta ( y - z ) * f ( y - b ) * f ( y - a ) * Heaviside ( x - y ) </s>
