# Change integration variable

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}]


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:

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.

• 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 Sep 3 '16 at 16:34
• Very useful function.+1 May 1 '20 at 11:18

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}])