First, let's look at what happens if we factor the ep
term out of the integral, like this
ClearAll[a, b, f, R, t]
ep = a + I b;
B = Integrate[f[t] , {t, -R, R}] ep;
With[{$Assumptions = Element[Integrate[ f[t], {t, -R, R}], Reals]},
Re[B] // ComplexExpand // Simplify
]
(* a*Integrate[f[t], {t, -R, R}] *)
So, it looks like MMA is able to apply the assumption that the integral is real. Note that we used With
to make a temporary change to the global $Assumptions
and we applied the assumptions using Simplify
. (The Simplify
takes about 12 seconds on my desktop. I wonder why.)
Next, we start with the ep
term inside the integral. This time we will use With
to set the $Assumptions
and to factor ep
, or any other contants, out of the integral, like this
ClearAll[a, b, f, R, t]
ep = a + I b;
B = Integrate[f[t] ep, {t, -R, R}]
With[{$Assumptions = Im@Integrate[ f[t], {t, -R, R}] == 0,
B = B //.
Integrate[q1___ r__ q2___, {v_, s___}] /; FreeQ[{r}, v] :>
r Integrate[q1 q2, {v, s}]},
(Re[B] // ComplexExpand // Simplify) /.
Times[r_, Integrate[q_, {v_, s___}]] /; FreeQ[{r}, v] :>
Integrate[r q, {v, s}]
]
(* Integrate[a*f[t], {t, -R, R}] *)
Note the different, but equivalent, assumptions in the two With
statements. Also note that factoring the constants out of the integral is done with code provided by @dr-belisarius in his answer to How to do algebra on unevaluated integrals?. Another reference that may be useful is How to simplify symbolic integration.