# help on simplification with integrals

V 12.1

How can one help Mathematica obtain zero for the following expression, by telling it that $$k$$ is really just a constant?

$$k \int_{-\infty }^{\infty } f(x) \, dx-\int_{-\infty }^{\infty } k f(x) \, dx$$

When we do the above by hand, clearly it is zero, because we pull constant out of the integral.

Clear["Global*"];
FullSimplify[
k Integrate[f[x], {x, -Infinity, Infinity}]-Integrate[k f[x], {x, -Infinity, Infinity}],
Assumptions -> {k > 0, Element[k, Reals]}]


(note, Element[k, Reals] is not really needed, since k>0 implies k is real.

Reduce does not do it either.

Fyi, Maple 2020:

restart;
simplify( k*int(f(x),x=-infinity..infinity) - int( k *f(x),x=-infinity..infinity) )
0

• It simplifies to 0 for the indefinite integrals k Integrate[f[x], x] - Integrate[k f[x], x] Commented Jun 7, 2020 at 16:44
• @BobHanlon Yes, I noticed that also. I think it should simplify to zero for both cases.Thanks. Commented Jun 7, 2020 at 22:50

Ok, found answer, thanks to how to simplify symbolic integration

Using the function moveconst given in the above thanks to celtschk

ClearAll["Global*"]
moveconst[x_] := (x /.
Integrate[factor_ expr_, {var_, min_, max_}] /;
FreeQ[factor, var] :> factor Integrate[expr, {var, min, max}]);


And now

Simplify[k Integrate[f[x], {x, -Infinity, Infinity}] -
Integrate[k f[x], {x, -Infinity, Infinity}],
TransformationFunctions -> {Automatic, moveconst}]

(* 0 *)


I am still not sure why this is needed, as k is clearly undefined symbol and hence does not depend on f[x]. But this is what is needed in Mathematica to get zero.