The main difficulty here is that Integrate
does not normally thread over addition. In other words, it does not understand that
$$\int f(x) + g(x) \text{d}x = \int f(x) \text{d}x + \int g(x) \text{d}x.$$
In most cases, it is true, but as integration is a limiting process care must be taken in the order of operations. A case where that is not true does not come to mind at the moment, other than involving infinite series, but it is not out of the question that a simplification in the integrand could obscure the relationship between the LHS and RHS, above. Mathematica, however, does understand
$$\int a(x) f(y) \text{d}y = a(x) \int f(y) \text{d}y,$$
as shown by
Integrate[a[x] u[y], y]
(*
a[x] Integrate[u[y], y]
*)
A method to achieve the form you are looking for is to Map
Integrate
across the sum, Expand[f[x,y]^2]
, as follows
ints = Integrate[#, y]& /@ Expand[f[x,y]^2]
(*
a[x]^2*Integrate[u[y]^2, y] + 2*a[x]*b[x]*Integrate[u[y]*v[y], y]
+ b[x]^2*Integrate[v[y]^2, y]
*)
Then, ReplaceAll
(/.
) works just fine,
ints /. Integrate[u[y]^2, y] -> I11
(*
I11*a[x]^2 + 2*a[x]*b[x]*Integrate[u[y]*v[y], y]
+ b[x]^2*Integrate[v[y]^2, y]
*)
Integrate[u[y]^2,y]
inIntegrate[ a[x]^2 u[y]^2 + 2 a[x] b[x] u[v] v[y] + b[x]^2 v[y]^2 , y]
... $\endgroup$/.
? $\endgroup$x
is independent ofy
, thenIntegrate[a[x]^2 u[y]^2, y] == a[x]^2 Integrate[u[y]^2, y]
. (Also, threading over the sum.) Not that Mathematica knows that. $\endgroup$Integrate[]
is very cautious that way... $\endgroup$