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.

Why does the following program lead to different results of a21 and a211?

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

inta1 = 2 (2 Cos[q3[t]] fec1[x1] q5[t] - fe1[x1] Sin[q3[t]] );
a1 = Integrate[inta1, {x1, 0, L1}] q6[t];

inta2 = (4 Cos[q3[t]] fec1[x1] q5[t] q6[t] -2 fe1[x1] Sin[q3[t]] q6[t]);
a2 = Integrate[inta2, {x1, 0, L1}];

a21 = a1 - a2;
Simplify[a21, TransformationFunctions -> {Automatic, moveconst}]


inta11 = 4 Cos[q3[t]] fec1[x1] q5[t] - 2 fe1[x1] Sin[q3[t]] ;
a11 = Integrate[inta11, {x1, 0, L1}] q6[t];

inta21 = (4 Cos[q3[t]] fec1[x1] q5[t] q6[t] - 2 fe1[x1] Sin[q3[t]] q6[t]);
a21 = Integrate[inta21, {x1, 0, L1}];

a211 = a11 - a21;
Simplify[a211, TransformationFunctions -> {Automatic, moveconst}]
share|improve this question
1  
Constants get pulled out of indefinite integrals but do not get pulled out of definite integrals. One major reason for this is that definite integrals may not exist while indefinite ones do. –  Searke Aug 22 '12 at 13:17

1 Answer 1

It looks like Simplify doesn't pull out numerical factors in certain integrals. A simple example being:

Simplify[Integrate[4 - 2 f[x], x] - 2 Integrate[2 - f[x], x]]

$\int (4-2 f[x]) \, dx-2 \int (2-f[x]) \, dx$

A workaround for your code is to add explicit factoring in your transformation function:

moveconst[x_] := (Map[Factor, x, -1] /. 
    Integrate[factor_ expr_, {var_, min_, max_}] /; 
      FreeQ[factor, var] :> factor Integrate[expr, {var, min, max}]);
share|improve this answer

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.