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$.
Asked
Active
Viewed 746 times
3
2 Answers
3
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...
M.R.
- 31,425
- 8
- 90
- 281
-
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}]. – egwene sedai Jan 08 '15 at 02:26 -
@davidsedai I added a rule for that, you can keep adding them for other cases if you want... – M.R. Jan 12 '15 at 17:09
1
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!
Alexei Boulbitch
- 39,397
- 2
- 47
- 96
ComplexityFunctionforSimplify.. ( search this site I think you might find some similar examples ) – george2079 Jan 07 '15 at 21:05TransformationFunctionsyou want, see here http://mathematica.stackexchange.com/questions/8353/why-arent-these-additions-of-integrals-and-summations-equal/8359#8359 – george2079 Jan 08 '15 at 16:38