I have trouble computing the numerator of this integral in Mathematica :

$$-\frac{3 \left(\int P(x,\kappa ) \left(Q^{(0,1)}(x,\kappa )+Q(x,\kappa )^2\right) \, dx\right)^2}{(\int P(x,\kappa ) \, dx)^2}$$

-((3*Integrate[P[x, κ]*(Q[x, κ]^2 + Derivative[0, 1][Q][x, κ]), x]^2) /
  Integrate[P[x, κ], x]^2)

I would like the integral of the sum to be split into the sum of the integrals so as to replace each integral by another expression. I have already tried using

Expand[Distribute //@ 
  -((3*Integrate[P[x, κ]*(Q[x, κ]^2 + Derivative[0, 1][Q][x, κ]), x]^2) /
    Integrate[P[x, κ], x]^2)]

but I ended up with

$$ -\frac{3 \left(\int P(x,\kappa ) Q^{(0,1)}(x,\kappa ) \, dx\right)^2}{(\int P(x,\kappa ) \, dx)^2}-\frac{3 \left(\int P(x,\kappa ) Q(x,\kappa )^2 \, dx\right)^2}{(\int P(x,\kappa ) \, dx)^2}, $$

which is not exactly what I want.

Does anyone know an easy way to split that integral properly?


I've tried

    -((3*Integrate[P[x, κ]*(Q[x, κ]^2 + Derivative[0, 1][Q][x, κ]), x]^2) /
      Integrate[P[x, κ], x]^2)],

but I got

$$-3 \left(\left(\int P(x,\kappa ) Q^{(0,1)}(x,\kappa ) \, dx\right)^2+\left(\int P(x,\kappa ) Q(x,\kappa )^2 \, dx\right)^2\right),$$

Not much better.

  • 2
    $\begingroup$ Can you just use Numerator? By the way, please post code with proper Mathematica syntax, properly formatted in code blocks, rather than post in TeX. People like to copy and paste code from posts into their own copies of Mathematica. $\endgroup$ – march Dec 1 '16 at 16:59
  • $\begingroup$ OK I didn't know, sorry ! I've just edited my post. And I'll try your suggestion ! $\endgroup$ – user5082172 Dec 1 '16 at 17:48
  • $\begingroup$ You may find this this meta Q&A helpful for tips on posting code to the site. $\endgroup$ – Michael E2 Dec 1 '16 at 18:12

you want something like this:

(Integrate[ p[x, y] ( q1[x, y] + q2[x, y] ), {x, 0, 1}])^2/
  denominator  /. 
 Integrate[ p[x, y] Plus[a_, b_], c_] :> 
  Integrate[ p[x, y] a, c] + Integrate[ p[x, y] b, c]

enter image description here

  • $\begingroup$ Yes ! I didn't know that symbol :>. What is it for ? Thank you !! $\endgroup$ – user5082172 Dec 1 '16 at 18:22
  • $\begingroup$ Or (Integrate[#, {x, 0, 1}] & /@ Expand[p[x, y] (q1[x, y] + q2[x, y])])^2/denominator or (Integrate[p[x, y]*#, {x, 0, 1}] & /@ (q1[x, y] + q2[x, y]))^2/denominator $\endgroup$ – Bob Hanlon Dec 1 '16 at 18:55

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.