1
$\begingroup$

As shown in the following program, the q[t] in a can be collected from the integration by defining the integration of fe1[x] as Infe1[x], the same is true for fe2[x] in b. But for the equation c, how can I collect q[t] from it?

fe1 /: Integrate[fe1[x_], x_] := Infe1[x];
fe2 /: Integrate[fe2[x_], x_] := Infe2[x];

a = Integrate[fe1[x]*q[t], {x, 0, L1}]

b = Integrate[fe2[x]*q[t], {x, 0, L1}]   

c = Integrate[fe1[x]*fe2[x]*q[t], {x, 0, L1}]
$\endgroup$
  • $\begingroup$ @SunnySky, if you want to convert typeset math (TraditionalForm) input into InputForm you can use Hold[ yourexpression ] // InputForm and copy and paste the bit inside Hold[]. $\endgroup$ – Verbeia Aug 29 '12 at 3:59
2
$\begingroup$

You could do it with a rule:

myrule = Integrate[Times[x_, q[t]], y_] :> q[t] Integrate[x, y]

c = Integrate[fe1[x]*fe2[x]*q[t], {x, 0, L1}] /. myrule

(*  ==>  Integrate[fe1[x]*fe2[x], {x, 0, L1}]*q[t]   *)

Edit:

For more generality, you could do

myrule2 = Integrate[Times[x_, c_], {y_, y1_, y2_}] /; FreeQ[c, y] :> c  Integrate[x, {y, y1, y2}];

Integrate[(1 + Exp[h[t]]^2) g[x, t] f[x] Exp[q[t]], {x, 0, L1}] //. myrule2

(* ==> E^q[t]*(1 + E^(2*h[t])) * Integrate[f[x]*g[x, t], {x, 0, L1}] *)

Note the use of ReplaceRepeated (//.) rather than just ReplaceAll (/.).

$\endgroup$
  • $\begingroup$ your answer works well. thank you very much. Moreover, If the q[t] is substituted by q[t]*g[t]*r[t] or even a more complex functions that depend on "t", then how can I collect them from the integration without defining rules for each special functions? $\endgroup$ – SunnySky Aug 29 '12 at 7:12
  • $\begingroup$ @SunnySky please see if the update helps you $\endgroup$ – ecoxlinux Aug 29 '12 at 14:26
  • $\begingroup$ yes, your answer is very good. may be "//. myrule" should be replaced by "//. myrule2". Thank you very much. $\endgroup$ – SunnySky Aug 30 '12 at 1:57
  • $\begingroup$ Indeed. Corrected. $\endgroup$ – ecoxlinux Aug 30 '12 at 2:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.