10

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}]
mikado
  • 16,741
  • 2
  • 20
  • 54

3 Answers3

13

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.

glS
  • 7,623
  • 1
  • 21
  • 61
4

In v13.1 IntegrateChangeVariables is introduced:

IntegrateChangeVariables[Inactive[Integrate][f[Sin[u]], {u, 0, Pi/2}],
  x, x == Sin[u]]
(* Inactive[Integrate][f[x]/Sqrt[1 - x^2], {x, 0, 1}] *)

enter image description here

But this function is still marked as EXPERIMENTAL and a bit fragile, so, watch your step :) :

(* This gives incorrect result: *)
IntegrateChangeVariables[Inactive[Integrate][f[Sin[u]], {u, 0, Pi/2}], 
  x, Sin[u] == x]
(* Inactive[Integrate][f[Sin[x]], {x, 0, π/2}] *)

enter image description here

xzczd
  • 65,995
  • 9
  • 163
  • 468
3

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}])
user127094
  • 31
  • 1