4
$\begingroup$

Is there a way to coerce Mathematica to join two integrals (with the same integrand) together? The simplest case is:

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

Clearly, this should be equal to Integrate[f[x], {x, 0, 2}].

This arose in solving a linear differential equation:

sys = D[y[t], t] == a y[t] + b u[t];
DSolve[{sys, y[0] == 0}, y[t], t]

enter image description here

This is a nice answer, but if you look at the form, the expressions inside the two integrals are identical. Thus y[t] ought to simplify to

enter image description here

But I cannot seem to get Mathematica to join the two integrals together. I've tried Simplify, FullSimplify, Expand, under a variety of assumptions, but can't seem to find a way to convince Mathematica to join the two together.

$\endgroup$

1 Answer 1

4
$\begingroup$

For this one, a brute force method can work

Unprotect@Integrate;
Integrate/:Integrate[ft_,{K[1],1,0}]-Integrate[ft_,{K[1],1,t}]:=-Integrate[ft,{K[1],0,t}];
Protect@Integrate;

And now

sys = D[y[t], t] == a y[t] + b u[t];
sol = y[t] /. First@DSolve[{sys, y[0] == 0}, y[t], t]

Mathematica graphics

You can change the above definition in the protect code, to make it more general, as I have hardcoded the limits for this specific problem.

$\endgroup$
3
  • 2
    $\begingroup$ It always makes me nervous changing the definitions of built-in functions. $\endgroup$
    – bill s
    Commented Dec 4, 2017 at 23:31
  • $\begingroup$ @bills I agree with you. But I do not know any other way. btw, Maple generates the short version directly. Here is screen shot !Mathematica graphics $\endgroup$
    – Nasser
    Commented Dec 4, 2017 at 23:55
  • 2
    $\begingroup$ @bills No risk, no fun! ;o) $\endgroup$ Commented Dec 4, 2017 at 23:59

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.