0
$\begingroup$

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
$\endgroup$
2
  • 1
    $\begingroup$ It simplifies to 0 for the indefinite integrals k Integrate[f[x], x] - Integrate[k f[x], x] $\endgroup$
    – Bob Hanlon
    Jun 7, 2020 at 16:44
  • $\begingroup$ @BobHanlon Yes, I noticed that also. I think it should simplify to zero for both cases.Thanks. $\endgroup$
    – Nasser
    Jun 7, 2020 at 22:50

1 Answer 1

2
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.