2
$\begingroup$

Considering the following term

(I*gm*knlt*om*Integrate[(dx10[om1] + x10bar[om1] - x20[om1])*(dx10[om - om1 - om2] + x10bar[om - om1 - om2] - x20[om - om1 - om2])*(dx10[om2] + x10bar[om2] - x20[om2]), {om1, -Infinity, Infinity}, 
   {om2, -Infinity, Infinity}])/(-(kext*kl) - I*gm*kext*om - (2*I)*gm*kl*om + gm^2*om^2)

I want to collect/keep only terms linear in the function x10bar (no matter of which argument). How would you do this in a swift way with Mathematica? I was trying to apply series expansion (which is difficult with functions) or pattern matching but failed so far.

Any help is highly appreciated!

[Edit]

The expected output should be

(I*gm*knlt*om*Integrate[dx10[om - om1 - om2]*dx10[om2]*x10bar[om1] + dx10[om1]*dx10[om2]*x10bar[om - om1 - om2] + dx10[om1]*dx10[om - om1 - om2]*x10bar[om2] - dx10[om2]*x10bar[om - om1 - om2]*x20[om1] - 
    dx10[om - om1 - om2]*x10bar[om2]*x20[om1] - dx10[om2]*x10bar[om1]*x20[om - om1 - om2] - dx10[om1]*x10bar[om2]*x20[om - om1 - om2] - x10bar[om2]*x20[om1]*x20[om - om1 - om2] - 
    dx10[om - om1 - om2]*x10bar[om1]*x20[om2] - dx10[om1]*x10bar[om - om1 - om2]*x20[om2] + x10bar[om - om1 - om2]*x20[om1]*x20[om2] + x10bar[om1]*x20[om - om1 - om2]*x20[om2], {om1, -Infinity, Infinity}, 
   {om2, -Infinity, Infinity}])/(-(kext*kl) - I*gm*kext*om - (2*I)*gm*kl*om + gm^2*om^2)
$\endgroup$
  • 1
    $\begingroup$ It would clarify what you want if you edit your question to show the desired output. $\endgroup$ – Bob Hanlon Jul 26 '18 at 18:22
1
$\begingroup$

Internal`LinearQ

{#, Internal`LinearQ[#, {x, y, z}]} & /@ 
  {1, x, y, a b c z, x + y + 3 z, a x^2 + y + z, x y z}

{{1, False},
{x, True},
{y, True},
{a b c z, True},
{x + y + 3 z, True},
{a x^2 + y + z, False},
{x y z, False}}

Taking only the integrand of the expression in OP and applying LinearQ:

integrand0 = Cases[expr0, Integrate[a_, b__] :> a][[1]]

(dx10[om1] + x10bar[om1] - x20[om1]) (dx10[om - om1 - om2] + x10bar[om - om1 - om2] - x20[om - om1 - om2]) (dx10[om2] + x10bar[om2] - x20[om2])

vars = Cases[integrand0, x10bar[__], Infinity]

{x10bar[om1], x10bar[om - om1 - om2], x10bar[om2]}

integrand1 = Select[ExpandAll[integrand0],  Internal`LinearQ[#, vars] &]

dx10[om - om1 - om2] dx10[om2] x10bar[om1] +
dx10[om1] dx10[om2] x10bar[om - om1 - om2] +
dx10[om1] dx10[om - om1 - om2] x10bar[om2] -
dx10[om2] x10bar[om - om1 - om2] x20[om1] -
dx10[om - om1 - om2] x10bar[om2] x20[om1] -
dx10[om2] x10bar[om1] x20[om - om1 - om2] -
dx10[om1] x10bar[om2] x20[om - om1 - om2] +
x10bar[om2] x20[om1] x20[om - om1 - om2] -
dx10[om - om1 - om2] x10bar[om1] x20[om2] -
dx10[om1] x10bar[om - om1 - om2] x20[om2] +
x10bar[om - om1 - om2] x20[om1] x20[om2] +
x10bar[om1] x20[om - om1 - om2] x20[om2]

$\endgroup$
0
$\begingroup$
expr = (I*gm*knlt*om*
     Integrate[(dx10[om1] + x10bar[om1] - 
         x20[om1])*(dx10[om - om1 - om2] + x10bar[om - om1 - om2] - 
         x20[om - om1 - om2])*(dx10[om2] + x10bar[om2] - 
         x20[om2]), {om1, -Infinity, Infinity}, {om2, -Infinity, 
       Infinity}])/(-(kext*kl) - I*gm*kext*om - (2*I)*gm*kl*om + 
     gm^2*om^2);

Use Inactive on Integrate to be able to ExpandAll its argument

expr2 = (expr /. Integrate -> Inactive[Integrate] // ExpandAll) /. 
   a_.*x10bar[__]*x10bar[_]*b_ :> 0 // Activate

(* (I*gm*knlt*om*Integrate[dx10[om1]*dx10[om - om1 - om2]*
            dx10[om2] + dx10[om - om1 - om2]*dx10[om2]*
            x10bar[om1] + dx10[om1]*dx10[om2]*
            x10bar[om - om1 - om2] + dx10[om1]*
            dx10[om - om1 - om2]*x10bar[om2] - 
          dx10[om - om1 - om2]*dx10[om2]*x20[om1] - 
          dx10[om2]*x10bar[om - om1 - om2]*x20[om1] - 
          dx10[om - om1 - om2]*x10bar[om2]*x20[om1] - 
          dx10[om1]*dx10[om2]*x20[om - om1 - om2] - 
          dx10[om2]*x10bar[om1]*x20[om - om1 - om2] - 
          dx10[om1]*x10bar[om2]*x20[om - om1 - om2] + 
          dx10[om2]*x20[om1]*x20[om - om1 - om2] + 
          x10bar[om2]*x20[om1]*x20[om - om1 - om2] - 
          dx10[om1]*dx10[om - om1 - om2]*x20[om2] - 
          dx10[om - om1 - om2]*x10bar[om1]*x20[om2] - 
          dx10[om1]*x10bar[om - om1 - om2]*x20[om2] + 
          dx10[om - om1 - om2]*x20[om1]*x20[om2] + 
          x10bar[om - om1 - om2]*x20[om1]*x20[om2] + 
          dx10[om1]*x20[om - om1 - om2]*x20[om2] + 
          x10bar[om1]*x20[om - om1 - om2]*x20[om2] - 
          x20[om1]*x20[om - om1 - om2]*x20[om2], 
        {om1, -Infinity, Infinity}, {om2, -Infinity, Infinity}])/
   ((-kext)*kl - I*gm*kext*om - 2*I*gm*kl*om + gm^2*om^2) *)

expr2 // FullSimplify

(* (I*gm*knlt*om*Integrate[(-dx10[om2])*x10bar[om - om1 - om2]*
            x20[om1] - dx10[om2]*x10bar[om1]*x20[om - om1 - om2] + 
          dx10[om2]*x20[om1]*x20[om - om1 - om2] + 
          x10bar[om2]*x20[om1]*x20[om - om1 - om2] + 
          (x10bar[om - om1 - om2]*x20[om1] + 
               (x10bar[om1] - x20[om1])*x20[om - om1 - om2])*
            x20[om2] + dx10[om - om1 - om2]*
            (dx10[om2]*(x10bar[om1] - x20[om1]) - 
               x10bar[om2]*x20[om1] + (-x10bar[om1] + x20[om1])*
                 x20[om2]) + dx10[om1]*
            (dx10[om2]*(x10bar[om - om1 - om2] - 
                    x20[om - om1 - om2]) + dx10[om - om1 - om2]*
                 (dx10[om2] + x10bar[om2] - x20[om2]) - 
               x10bar[om - om1 - om2]*x20[om2] + x20[om - om1 - om2]*
                 (-x10bar[om2] + x20[om2])), {om1, -Infinity, 
          Infinity}, {om2, -Infinity, Infinity}])/
   ((-kext)*kl - I*gm*(kext + 2*kl)*om + gm^2*om^2) *)
$\endgroup$

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.