I am new to Mathematica and I just tried to play around with some integrals. But the sum rule in integration doesn't work.

Here a simple example: Mathematica doesn't recognize that $\int_0^h (1-f(x)) \, dx$ and $h-\int_0^h f(x) \, dx$ are the same.


Reduce[Integrate[1 - f[x], {x, 0, h}] == h - Integrate[f[x], {x, 0, h}]] 

I just get the output of

Reduce::nsmet: This system cannot be solved with the methods available to Reduce. >>

Is that normal? If not, where is the error?


1 Answer 1


The reason is because Mathematica does not know anything about f[x]. What if f[x] was 1? then the integrand will be zero. One way is to make your own rule for this case.

ClearAll[x, y, h, f];
rul0[x_] := (x /. Integrate[1 - f[y_], {y_, a_, b_}] :> ((b - a) - Integrate[f[y], {y, a, b}]))
Simplify[Integrate[1 - f[x], {x, 0, h}], TransformationFunctions -> rul0]

Mathematica graphics

Simplify[Integrate[1 - f[x], {x, 0, h}] == h - Integrate[f[x], {x, 0, h}], 
     TransformationFunctions -> {rul0}]
(* True *)

There is also a known method to do this, but for some reason it does not work for me on version 10. If I figure why that method is not working, will add a way to do this using that method.

Version 10, windows 7

update 1

Thanks to Jens for finding a fix to the method he showed in the link I mentioned above to make it now work in version 10 (this method worked in version 8 but for some reason it stopped working in version 9 and 10), this is below alternative (and better) way to do this since no special rule is used

 f /: Integrate[f[x_], x_] := ff[x]
 SetAttributes[ff, {NumericFunction}]

Now, once the above is defined, you can do what you want directly:

 Simplify[Integrate[1 - f[x], {x, 0, h}]]
 (* h + ff[0] - ff[h] *)


Simplify[Integrate[1 - f[x], {x, 0, h}] == h - Integrate[f[x], {x, 0, h}]]
  (*  True *)

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