0

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]}]

Mathematica graphics

(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
Nasser
  • 143,286
  • 11
  • 154
  • 359

1 Answers1

2

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.

Nasser
  • 143,286
  • 11
  • 154
  • 359