# Let mathematica combine integral limits

Is there a way to teach mathematica to combine integral limits according to $\int_a^b f dx+\int_b^c f dx=\int_a^cf dx$ to simplify expressions like $\int_0^1 f[t] dt+\int_1^x (1+f[t]) dt$ to $\int_0^t f[t] dt+x-1$ ? Additionally, it'll be helpful for mathematica to know $-\int_b^a f dx+\int_b^c f dx=\int_a^cf dx$ is equvalent to $\int_a^b f dx+\int_b^c f dx=\int_a^cf dx$.

• You might tackle this by designing a ComplexityFunction for Simplify .. ( search this site I think you might find some similar examples ) Jan 7, 2015 at 21:05
• Im sorry, it is TransformationFunctions you want, see here mathematica.stackexchange.com/questions/8353/… Jan 8, 2015 at 16:38
• @george2079 Excellent! Problem solved. Jan 9, 2015 at 1:42

You're looking for TagSetDelayed I believe:

Unprotect@Integrate;
Integrate /:
Plus[Integrate[ft_, {t_, a_, b_}], Integrate[ft_, {t_, b_, c_}]] :=
Integrate[ft, {t, a, c}];
Integrate /:
Plus[Integrate[ft_, {t_, b_, a_}], Integrate[ft_, {t_, b_, c_}]] :=
Integrate[ft, {t, a, c}];
Protect@Integrate;


But be careful when you unprotect system functions...

• Thanks! It works for Integrate[f[t], {t, a, b}] + Integrate[f[t], {t, b, c}] but not -Integrate[f[t], {t, b, a}] + Integrate[f[t], {t, b, c}]. Jan 8, 2015 at 2:26
• @davidsedai I added a rule for that, you can keep adding them for other cases if you want...
– M.R.
Jan 12, 2015 at 17:09

One may also use Inactivate/Activateconstruct. For example, try this

expr = Inactivate[
Integrate[f[x], {x, 0, 1}] + Integrate[f[x], {x, 1, 2}], Integrate]


yielding this:

Then make the replacement:

    expr /. Inactivate[
Integrate[g_, {x, a_, b_}] + Integrate[g_, {x, b_, c_}],
Integrate] -> Inactivate[Integrate[g, {x, a, c}], Integrate]


giving this:

Then let us activate the result:

 % // Activate


returning this:

Let us also check it with a certain function f[x], say, with x^2:

 expr1 = Inactivate[
Integrate[x^2, {x, 0, 1}] + Integrate[x^2, {x, 1, 2}], Integrate]


expr1 /. Inactivate[
Integrate[g_, {x, a_, b_}] + Integrate[g_, {x, b_, c_}],
Integrate] -> Inactivate[Integrate[g, {x, a, c}], Integrate]


   % // Activate

(*  8/3 *)


Have fun!