I am trying to do algebra on unsolved integrals but not getting the pattern-matching right. I want the correlation of f[x] and f[x]+a*d[x], normalized by their self correlations.
crInt[f_, g_, x_] := Inactive[Integrate][Expand[f[x]*g[x]], {x, -Infinity, Infinity}];
defInt[f_, x_] := Inactive[Integrate][f[x], {x, -Infinity, Infinity}];
corr[f_, g_, x_] := crInt[f, g, x] - defInt[f, x]*defInt[g, x];
h1 = corr[f, g, x]/Sqrt[corr[f, f, x]*corr[g, g, x]];
h2 = h1 /. g[x] -> f[x] + a*d[x];
h3 = h2 /. Integrate[q_, {v_, s__}] :> Distribute@Integrate[Expand[q], {v, s}];
h4 = h3 /. Integrate[q1___ r__ q2___, {v_, s__}] /; FreeQ[{r}, v] :> r Integrate[q1 q2, {v, s}]
The Expand/Distribute in the h3 line isn't Expanding the integrand, so the Distribute can't work.
In the h4 line, I'm trying to move any constants outside the integral, but I'm not sure I understand the difference between /. and //.
This Question builds on the discussion from my earlier question: How to do algebra on unevaluated integrals?
Distributewon't work, because it has the wrong form (check the documentation). Second: I think to matchIntegrate, you need to actually putInactive[Integrate]. Third: It seems like your definitions of the correlation functions and such are creating things likedx^2, which I don't understand. Edit: nope, nevermind, I misinterpreted the^2that was attached to the entire integral. – march Aug 11 '15 at 21:32