0

I would like to give a condition that the integral I am handling are not complexes.

Consider

$Assumptions=Element[a,Reals] && Element[b,Reals] && Element[t,Reals] && Element[f[t],Reals] && Element[R,Reals] && Element[Integrate[b f[t],{t,-R,R}],Reals]

ep = a + I b;

B=Integrate[ComplexExpand[f[t] ep],{t,-R,R}] // Distribute

Re[B] //Distribute

The output is:

Re[Integrate[a f[t], {t, -R, R}]] + Re[Integrate[I b f[t], {t, -R, R}]]

I think that is can't simplify because it may happen that the value of the integral (even if the integrand is real) is complex, how can I tell mathematica to give the result : Integrate[a f[t], {t, -R, R}]

Smilia
  • 592
  • 4
  • 14

1 Answers1

1

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 ]

(* aIntegrate[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[af[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.

LouisB
  • 12,528
  • 1
  • 21
  • 31