# Mathematica 12.1 integrates functions individually but not their sum

I found something odd in MMA 12.1 when symbolically integrating DiracDelta and Piecewise. These functions are integrated individually but not their sum. The following code

f[x_] = DiracDelta[x - 12.0];
Integrate[f[x], x]
g[x_] = Piecewise[{{2 x, x < 1}, {4 x, 1 <= x < 2}, {0, True}}];
Integrate[g[x], x]
Integrate[f[x] + g[x], x]


produces evaluated integrals in the first two cases but not in the third case. Why?

$$\theta (x-12.)$$

$$\begin{cases} x^2 & x\leq 1 \\ 2 x^2-1 & 1

$$\int \left(\left( \begin{cases} 2 x & x<1 \\ 4 x & 1\leq x<2 \\ \end{cases} \right)+\delta (x-12.)\right) \, dx$$

By the way, symbolic Python works as expected.

from sympy import *
x=var('x')
f=DiracDelta(x)
g=Piecewise((1,x<3), (2,x<10),(0,True))
integrate(f+g,x)

• I would be super careful about computing indefinite integrals where the integrand is a delta function. I'm not sure that even makes any sense. Instead, you should be using definite integrals. For instance, consider the result of Integrate[f[x], {x, a, b}, Assumptions -> {a < b}]. Commented Feb 25, 2022 at 18:23

Distribute[Integrate[f[x] + g[x], x]]

• It probably has to due with the fact that while g[x] is piecewise continuous, it is not smooth at the transitions, i.e., it is not differentiable at the transitions. Look at D[g[x], x]. Consequently, D[Integrate[g[x], x], x] == g[x] // PiecewiseExpand is a condition rather than True. In the more complicated context, Integrate balks. Commented Feb 25, 2022 at 14:25
• I would like to point out that symbolic Python has absolutely no problems with this. from sympy import * x=var('x') f=DiracDelta(x) g=Piecewise((1,x<3), (2,x<10),(0,True)) integrate(f+g,x) Commented Feb 25, 2022 at 15:00