From: Mark McClure on 1 Jun 2010 04:20 On Sun, May 30, 2010 at 11:45 PM, Jesse Perla <jesseperla(a)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
From: Bob Hanlon on 1 Jun 2010 04:20 Integrate[#, {z, clow, chigh}] & /@ (a + z + s[z]) Bob Hanlon ---- Jesse Perla <jesseperla(a)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}] However, FullSimplify, etc. don't seem to do anything with this. Any ideas?
|
Pages: 1 Prev: Problems running Mathematica and WordMS together in Next: FSolve package |