# Equation Simplification in Mathematica

I wonder if the following equation could be further simplified by Mathematica. There are $22$ Integrals involved and many of them are in the range $y_l$ and $y_u$. I would guess that at least those terms could be collected in the same integral. I used the command FullSimplify but the result is the same with the input. Are there some more clever ways to simplify such type of equations?

(2*(1 - \[Epsilon]0)^2*Integrate[((Sqrt[f1[y]*l[yu]] - Sqrt[f0[y]*l[yl]
*l[yu]])*(-Sqrt[f1[y]*l[yl]] + Sqrt[f0[y]*l[yl]*l[yu]]))/(-Sqrt[l[yl]] +
Sqrt[l[yu]])^2, {y, yl, yu}] - 2*(Integrate[(Sqrt[f0[y]]*(-Sqrt[f1[y]*l[yl]] +
Sqrt[f0[y]*l[yl]*l[yu]]))/(-Sqrt[l[yl]] + Sqrt[l[yu]]), {y, yl, yu}] +
Integrate[f0[y], {y, -Infinity, yl}]*Sqrt[l[yl]])*(Integrate[(Sqrt[f0[y]]*
(Sqrt[f1[y]*l[yu]] - Sqrt[f0[y]*l[yl]*l[yu]]))/(-Sqrt[l[yl]] + Sqrt[l[yu]]),
{y, yl, yu}] + Integrate[f0[y], {y, yu, Infinity}]*Sqrt[l[yu]]) -
Sqrt[(-2*(1 - \[Epsilon]0)^2*Integrate[((Sqrt[f1[y]*l[yu]] -
Sqrt[f0[y]*l[yl]*l[yu]])*(-Sqrt[f1[y]*l[yl]] +
Sqrt[f0[y]*l[yl]*l[yu]]))/(-Sqrt[l[yl]] + Sqrt[l[yu]])^2, {y, yl, yu}] +
2*(Integrate[(Sqrt[f0[y]]*(-Sqrt[f1[y]*l[yl]] +
Sqrt[f0[y]*l[yl]*l[yu]]))/(-Sqrt[l[yl]] + Sqrt[l[yu]]), {y, yl, yu}] +
Integrate[f0[y], {y, -Infinity, yl}]*Sqrt[l[yl]])*(Integrate[(Sqrt[f0[y]]*
(Sqrt[f1[y]*l[yu]] - Sqrt[f0[y]*l[yl]*l[yu]]))/(-Sqrt[l[yl]] +
Sqrt[l[yu]]), {y, yl, yu}] + Integrate[f0[y], {y, yu, Infinity}]*
Sqrt[l[yu]]))^2 - 4*((Integrate[(Sqrt[f0[y]]*(-Sqrt[f1[y]*l[yl]] +
Sqrt[f0[y]*l[yl]*l[yu]]))/(-Sqrt[l[yl]] + Sqrt[l[yu]]), {y, yl, yu}] +
Integrate[f0[y], {y, -Infinity, yl}]*Sqrt[l[yl]])^2 -
(1 -\[Epsilon]0)^2*(Integrate[(Sqrt[f0[y]]*(-Sqrt[f1[y]*l[yl]] +
Sqrt[f0[y]*l[yl]*l[yu]])^2)/(-Sqrt[l[yl]] + Sqrt[l[yu]])^2, {y, yl, yu}] +
Integrate[f0[y], {y, -Infinity, yl}]*l[yl]))*((Integrate[(Sqrt[f0[y]]*
(Sqrt[f1[y]*l[yu]] - Sqrt[f0[y]*l[yl]*l[yu]]))/(-Sqrt[l[yl]] +
Sqrt[l[yu]]), {y, yl, yu}] + Integrate[f0[y], {y, yu, Infinity}]*
Sqrt[l[yu]])^2 - (1 - \[Epsilon]0)^2*(Integrate[(Sqrt[f1[y]*l[yu]] -
Sqrt[f0[y]*l[yl]*l[yu]])^2/(-Sqrt[l[yl]] + Sqrt[l[yu]])^2, {y, yl, yu}] +
Integrate[f0[y], {y, yu, Infinity}]*l[yu]))])/(2*((Integrate[(Sqrt[f0[y]]*
(Sqrt[f1[y]*l[yu]] - Sqrt[f0[y]*l[yl]*l[yu]]))/(-Sqrt[l[yl]] + Sqrt[l[yu]]),
{y, yl, yu}] + Integrate[f0[y], {y, yu, Infinity}]*Sqrt[l[yu]])^2 -
(1 - \[Epsilon]0)^2*(Integrate[(Sqrt[f1[y]*l[yu]] -
Sqrt[f0[y]*l[yl]*l[yu]])^2/(-Sqrt[l[yl]] + Sqrt[l[yu]])^2, {y, yl, yu}]
+Integrate[f0[y], {y, yu, Infinity}]*l[yu])))

• How about trying two of them first? If that works, then go to three... – bill s Feb 28 '14 at 2:18
• @bills thanks for the comment. There are $22$ but they are not in the form of simple summations. Sometimes multiplications and some times in the phranthesis etc. Please have a look at it via printing the equations. Seemed complicated to deal one by one to me. – Seyhmus Güngören Feb 28 '14 at 2:20
• There is a quite dirty four letters word for this kind of thing. It's called "work" – Dr. belisarius Feb 28 '14 at 3:08
• @belisarius lets dont call it as dirty. It is usually what we usually do.. This formula is also a result of such long series of dirty algebra by hand. Then I had to give it to mathematica, because i had to find the roots of a polynomial of degree $2$. The result is as above. Now which is dirtier? trying to write these equations back to papers and try to reduce by hand or try to find a way in mathematica so that a simplification can be done. I think both) – Seyhmus Güngören Feb 28 '14 at 11:56
• To be or not to be ...:) – Dr. belisarius Feb 28 '14 at 12:16

Let's say your expression is expr. Then you can parse this this way, first let's take a look at a structure of the expr, in order to do this we can create a list of substititutions. Of course we are doing this because we have seen that there are common terms involving integrals:

 (subs = With[{set = Cases[expr, _Integrate, ∞] // DeleteDuplicates},
Table[set[[i]] :> Evaluate@int[i], {i, Length@set}]]

) // Grid[{#}\[Transpose], Alignment -> Right, BaseStyle -> {18}] & expr /. subs If you take a closer look you can see that there are no terms that could be collected inside common integral.

Even if there would be it can be tough according to Why aren't these additions of integrals and summations equal?

So as you can see FullSimplify is not enough to do this. (in the case where it can be done) Distributing Integrate is quite easy and is shown in the linked answer. If you want to gather terms to the common Integrate you can try with the following pattern:

5 Integrate[f[x], {x, x1, x2}] - 2 Integrate[g[x], {x, x1, x2}] //. (
con1_. Integrate[a_, {x_, l__}] + con2_. Integrate[b_, {x_, l__}]) :>
Integrate[con1 a + con2 b, {x, l}] /; D[con1, x] == 0 && D[con2, x] == 0 • thank you very much for the answer. – Seyhmus Güngören Apr 23 '14 at 21:33
• @SeyhmusGüngören That's great you find it useful :) Good luck! – Kuba Apr 23 '14 at 21:35