How to simplify the integration result of the following program?

In the following program, the fec[x] is a function depending on $x$ while q3[t] and q5[t] are functions depending on $t$. Now, I want to use Integrate for the polynomial which is composed by fec[x], q3[t], q5[t], et al. for the independent variable $x$. I believe the result c is zero, but I don' t know why the software could not convert it to zero automatically. Could you help me?

inta = Cos[q3[t]] fec[x] q5[t]^2 D[q3[t], t]^2;
a = Integrate[inta, {x, 0, L1}];

b1 = Cos[q3[t]] q5[t]^2 D[q3[t], t]^2;
b = Integrate[fec[x], {x, 0, L1}] b1;

c = a - b;


The problem can be distilled to a much simpler form to help illustrate what is going on. (whenever you find a problem, try to find the most simple form that shows the problem)

It has to do with definite vs. indefinite integration.

Clear[q, x, L1]
Integrate[q[x]*f[t], x]

Out[52]= f[t]*Integrate[q[x], x]


You see that now it pulled the function that does not depend on the integration variable out.

Do the same, now using definite integration

Clear[q, x, L1]
Integrate[q[x]*f[t], {x, 0, L1}]

Out[54]= Integrate[f[t]*q[x], {x, 0, L1}]


You see, the f[t] remained inside. I am not a math guy, so can't explain why it does not remove f[t] out when it is a definite integration. But it looks like when it is definite integration, you need to tell it that those functions that explicitly depend on t and not x remain independent of x for the definite case. I do not know how to do this.

That is why this gives zero

Integrate[q[x]*f[t], x]-f[t]Integrate[q[x], x]
Out[55]= 0


while the definite version does not (which is what you are basically asking)

Integrate[q[x]*f[t], {x, 0, L1}] - f[t]*Integrate[q[x], {x, 0, L1}]
Out[56]= (-f[t])*Integrate[q[x], {x, 0, L1}] + Integrate[f[t]*q[x], {x, 0, L1}]


Just wanted to point the problem more clearly that is all.

Edit

Additional observation. It seems the simplification does not happen becuase Mathematica does not know that f[x] does not depend implicitly on t. See:

Clear[x,t,f,g,L1]
Integrate[x*g[t],{x,0,L1}]-g[t]*Integrate[x,{x,0,L1}]

Out[14]= 0


Becuase it now sees that f[x] really does NOT really depend on t, then it pulled out g[t] and we get zero.

But when we write

 Clear[x, t, f, g, L1]
Integrate[f[x]*g[t], {x, 0, L1}] - g[t]*Integrate[f[x], {x, 0, L1}]

Out[17]= (-g[t])*Integrate[f[x], {x, 0, L1}] + Integrate[f[x]*g[t], {x, 0, L1}]


So, may be some assumptions is needed. Not sure now. Just thought to mention this.

You could use the trick @Jens showed here. See his post (and upvote it!) for an explanation:

fec /: Integrate[fec[x_], x_] := Intfec[x];
SetAttributes[Intfec, {NumericFunction}];

inta = Cos[q3[t]] fec[x] q5[t]^2 D[q3[t], t]^2;
a = Integrate[inta, {x, 0, L1}];

b1 = Cos[q3[t]] q5[t]^2 D[q3[t], t]^2;
b = Integrate[fec[x], {x, 0, L1}] b1;

a - b
(*
-> 0
*)

• Dear Verde, Thanks for your help, and now my problem has been resolved. – SunnySky Aug 24 '12 at 6:34
• I edited your answer to add a fix for version 10 that I also used in the answer you linked to. – Jens Aug 29 '14 at 17:24
• @Jens Thanks! No v10 here yet, unable to test :( – Dr. belisarius Aug 29 '14 at 18:41