Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

The following is the code:

    In[3]:= Simplify[Integrate[f[x]*c, {x, a, b}]/c, Assumptions -> c > 0]

    Integrate[c f[x], {x, a, b}]
    ----------------------------
                c

but obviously the right answer should be:

    Integrate[f[x], {x, a, b}]

how to solve it without placing c outside the integrate function?

share|improve this question
    
how about Simplify[Integrate[f[x]*c, {x, a, b}]/c/. Integrate-> int]/. int-> Integrate? –  chris May 16 '12 at 2:07
    
the same problem. –  howard May 16 '12 at 2:12
    
@chris If you first define int[c_Symbol*f_, dom_] := c*int[f, dom] or some such, then that should work fine. –  Mark McClure May 16 '12 at 2:13
    
yes,it works,but we may need more code to take out the variable from the expression. –  howard May 16 '12 at 2:32
    
@howard What expression?? –  Mark McClure May 16 '12 at 2:58

3 Answers 3

up vote 7 down vote accepted

You can tell Mathematica that it may move multiplicative constants out of the integral by defining the function

moveconst[x_]:=(x /.
  Integrate[factor_ expr_, {var_, min_, max_}] /; FreeQ[factor, var] :>
  factor Integrate[expr, {var, min, max}])

and then using

Simplify[Integrate[f[x]*c, {x, a, b}]/c, Assumptions -> c > 0,
         TransformationFunctions->{Automatic, moveconst}]
(*
==> Integrate[f[x], {x, a, b}]
*)

Note that Mathematica only uses the transformation if it really makes the expression simpler:

Simplify[Integrate[f[x]*c, {x, a, b}], Assumptions -> c > 0,
         TransformationFunctions->{Automatic, moveconst}]
(*
==> Integrate[c f[x], {x, a, b}]
*)

Here, moving the constant out of the integral would not have simplified the expression, therefore Mathematica doesn't do it.

share|improve this answer
    
@ celtschk,Thanks! problem solved. –  howard May 16 '12 at 12:47

There is no way to do exactly what you want because an assumption can't be used to tell Mathematica that there exists an indefinite integral of the unknown function f[x]. See for example this MathGroup post.

However, you can get almost what you need if you define the indefinite integral yourself in the following way:

f /: Integrate[f[x_], x_] := ff[x]

This declares ff[x] as the anti-derivative of f[x]. Now we can get somewhere with the symbolic integration:

Simplify[Integrate[c f[x], {x, a, b}]/c]

-ff[a] + ff[b]

By using the delayed assignment (TagSetDelayed) for the indefinite integral, it's also possible to use other integration variables, as in

Simplify[Integrate[c f[t], {t, a, b}]/c]

-ff[a] + ff[b]

Edit

The advantage of this approach is that it also helps with other simplifications whose pattern you may not have foreseen at the outset. If you follow the pattern-matching micromanagement approach of the other answers, you'd have to introduce new patterns for new cases. For example, I can also simplify the integral:

Simplify[Integrate[c + f[x], {x, a, b}]]

(-a + b) c - ff[a] + ff[b]

And one could go on...

share|improve this answer
    
very good! Thank you! –  howard May 16 '12 at 2:37
    
This seemed the most mathematically kosher way to deal with the situation. But I just noticed I should make the indefinite integral independent of the variable name x. I'll modify my answer by using a TagSetDelayed instead of TagSet. –  Jens May 16 '12 at 2:55
    
Very nice! I used your solution here mathematica.stackexchange.com/a/9683/193, with due credit. –  belisarius Aug 21 '12 at 11:50

This is quite probably ill-advised, but

Clear[mysimp];
mysimp[Integrate[c_Symbol*f_[x_], {x_, a_, b_}]] := 
  c*Integrate[f[x], {x, a, b}];
mysimp[h_[x__]] := Map[mysimp, h[x]];
mysimp[x_?AtomQ] := x;
mysimp[Integrate[c*f[x], {x, a, b}]/c] // InputForm

Integrate[f[x], {x, a, b}]

These patterns are written quite specifically for your example, though. I don't expect this to be generally useful.

share|improve this answer
    
ok,good,thank you! –  howard May 16 '12 at 3:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.