7
$\begingroup$

Are there any automated procedures to change integration variables? For example by changing Sin[u]->x, I can change

Integrate[f[Sin[u]], {u, 0, Pi/2}]

into

Integrate[f[x]/Sqrt[1 - x^2], {x, 0, 1}]
$\endgroup$
12
$\begingroup$

Here is a possibly quite naive implementation:

changeVariables[expr_, oldVar_, changeFunc_, newVar_, interval_] := With[{
    inverse = InverseFunction @ changeFunc,
    der = D[changeFunc @ oldVar, oldVar]
  },
  {
    (expr /. changeFunc @ oldVar -> newVar) / (
      der /. oldVar -> inverse @ newVar
    ),
    {newVar, changeFunc @ interval[[1]], changeFunc @ interval[[2]]}
  }
]

which gives the expected result, in at least simple circumstances:

enter image description here

Of course, as the warning reminds us, this method uses inverse functions and may, therefore, give incorrect results in some circumstances. Already in my second example had I used as integration interval $(-\infty,\infty)$ I would have got a wrong result.

$\endgroup$
2
  • 1
    $\begingroup$ Mathematica will rarely (if ever) change the variable of integration in integrals it cannot evaluate. Your function could be very useful in such cases. Thanks $\endgroup$
    – mikado
    Sep 3 '16 at 16:34
  • 2
    $\begingroup$ Very useful function.+1 $\endgroup$
    – tanghe2014
    May 1 '20 at 11:18
3
$\begingroup$

Sorry, not allowed to comment on glS' answer. I found the following useful, which builds a rule to change variables in (all!) integrals, building on changeVariables above:

changeVariableRule[changeFunc_, 
  newVar_] := (Integrate[expr_, {x_, start_, stop_}] :> 
   Integrate @@ 
    changeVariables[expr, x, changeFunc, newVar, {start, stop}])
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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