3
$\begingroup$

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$.

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

2 Answers 2

3
$\begingroup$

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...

$\endgroup$
2
  • $\begingroup$ 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}]. $\endgroup$ Jan 8, 2015 at 2:26
  • $\begingroup$ @davidsedai I added a rule for that, you can keep adding them for other cases if you want... $\endgroup$
    – M.R.
    Jan 12, 2015 at 17:09
1
$\begingroup$

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:

enter image description here

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:

enter image description here

Then let us activate the result:

 % // Activate

returning this:

enter image description here

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]

enter image description here

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

enter image description here

   % // Activate

(*  8/3 *)

Have fun!

$\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.