Is there an obvious way to force Mathematica to separately integrate the terms in a sum? According to the docs,
When part of a sum cannot be integrated explicitly, the whole sum will stay unintegrated.
But I want to do this because some of the terms have a nice closed form, and some don't, but I want to compute the former.
Here's what I've done; it works, but it seems inelegant:
integrand = m^2 + mp^2 + mp f[mp] (* the actual integrand is much more complicated! *)
(myint[integrand // Expand]
//. myint[a_ + b_] :> myint[a] + myint[b]
//. myint[i_] :> Integrate[i, {mp, -1, 1}]) // FullSimplify
Which gives the correct
2/3 + 2*m^2 + Integrate[mp*f[mp], {mp, -1, 1}]
Distribute- +1. – Leonid Shifrin Dec 11 '12 at 17:29Distributewill work on the result. You probably do want this behavior in most cases, but I can also imagine cases where you don't want the full integration to be attempted. You could of course use this one withUnevaluatedin those cases too. – Leonid Shifrin Dec 11 '12 at 17:32MapnorDistributeabsolve you from using common sense. For example, just likeMapcan be misused on non-sums, you can equally misuseDistributewith non-distributable operations! For example, don't try this at home:Power[integrand, 2] // Distribute– Jens Dec 11 '12 at 18:06