1
$\begingroup$

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}]
$\endgroup$
1
  • 1
    $\begingroup$ 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. $\endgroup$
    – Searke
    Commented Aug 22, 2012 at 13:17

1 Answer 1

2
$\begingroup$

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}]);
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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