Re: Expanding Integrals with constants and 'unknown'

*To*: mathgroup at smc.vnet.net*Subject*: [mg110070] Re: Expanding Integrals with constants and 'unknown'*From*: Mark McClure <mcmcclur at unca.edu>*Date*: Tue, 1 Jun 2010 04:21:08 -0400 (EDT)

On Sun, May 30, 2010 at 11:45 PM, Jesse Perla <jesseperla at gmail.com> wrote: > I have an integral involving constants and an 'unknown' function. I > would like to expand it out to solve for the constants and keep the > integrals of the unknown function as expected. > i.e. > Integrate[a + z + s[z], {z, clow, chigh}] > > I want to get out: > (a*chigh + chigh^2/2 - a*clow - clow^2/2) + Integrate[s[z], {z, clow, > chigh}] You could write a function that is explicitly linear but calls Integrate otherwise. Here's a small modification of your example that also illustrates constant multiples. In[70]:== Clear[int]; int[expr_Plus, {var_, low_, high_}] :== Map[int[#, {var, low, high}] &, expr]; int[expr_Times, {var_, low_, high_}] :== With[ {c == Select[expr, FreeQ[#, var] &]}, c*int[expr/c, {var, low, high}]]; int[expr_, {var_, low_, high_}] :== Integrate[expr, {var, low, high}]; int[a + z + 5 c*s[z], {z, clow, chigh}] // InputForm Out[74]//InputForm== chigh^2/2 + a*(chigh - clow) - clow^2/2 + 5*c*Integrate[s[z], {z, clow, chigh}] Mark McClure