# how to simplify symbolic integration

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?

-
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

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.

-
@ celtschk,Thanks! problem solved. – howard May 16 '12 at 12:47

Edit for Mathematica version 9 and higher

To make this answer work with definite integrals in versions greater than 8, I added the line with SetAttributes in the definition below. Without declaring the antiderivative ff as a NumericFunction, the simplifications that were done in version 8 don't kick in, and the expressions remain unevaluated.

End edit

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]
SetAttributes[ff, {NumericFunction}]


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...

-
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
I tried this in V9 and V10 and it didn't do anything. Can you please confirm that it still works? – Pickett Aug 29 '14 at 10:32
@Pickett Thanks for letting me know, anyway - maybe I'll report it as a bug - finding out that old code no longer works seems one of the constant battles in Mathematica. But I've had worse (recalling version 5 -> 6 and then again 6 -> 7)... – Jens Aug 29 '14 at 16:36
@Picket I've submitted a bug report[CASE:1477670], but I figured out a fix, see my edit. – Jens Aug 29 '14 at 17:21

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.

-
ok,good,thank you! – howard May 16 '12 at 3:23