# Trouble splitting an integral in Mathematica

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?

### Edit

I've tried

Map[
Distribute,
Numerator[
-((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.

• 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. Dec 1, 2016 at 16:59
• OK I didn't know, sorry ! I've just edited my post. And I'll try your suggestion ! Dec 1, 2016 at 17:48
• You may find this this meta Q&A helpful for tips on posting code to the site. Dec 1, 2016 at 18:12