# How to define a function that can transform integrands to the unit hypercube?

We know most integrands can easily be transformed to the unit hypercube: $$\int_{a_1}^{b_1}\cdots\int_{a_d}^{b_d}{\rm d}^{d}x\, f(\vec{x})=\int_0^1{\rm d}^dx\,f(\vec{x})\prod_{i=1}^{d}(b_i-a_i)\ ,$$ where $$x_i=a_i+(b_i-a_i)y_i$$, you can see this document at page3: ACAT 05. Such as, $$\int_a^b{\rm d}x\,f(x)=\int_0^1{\rm d}y\,f\big(a+(b-a)y\big)(b-a)\ .$$ We also have other transformative method, such as, $$\int_a^{+\infty}{\rm d}x\, f(x)=\int_0^1{\rm d}t\,f\big(a+(1-t)/t\big)/t^2\ ,$$ $$\int_{-\infty}^{+\infty}{\rm d}x\,f(x)=\int_0^1{\rm d}t\,\Big[f\Big((1-t)/t\Big)+f\Big(-(1-t)/t\Big)\Big]/t^2\ ,$$ $$\int_{-\infty}^b{\rm d}x\, f(x)=\int_0^1{\rm d}t\,f\Big(b-(1-t)/t\Big)/t^2 \ .$$

Now my question is: How to define a function that can transform integrands to the unit hypercube? It maybe have follow form:

formatting[fun_,{x_,xmin_,xmax_},{y_,ymin_,yMax_},...]:=(* Define *)

When I calculate $$\int_0^{+\infty}\exp(-x)\cdot\sin(x){\rm d}x\ .$$ I use function

formatting[Exp[-x]*Sin[x],{x,0,\[Infinity]}]

I can get $$\exp\Big(-(1-t)/t\Big)\cdot\sin\Big((1-t)/t\Big)/t^2 \ .$$

I think I can use Which to construct this function, but branch is too many.

A simple way is to use the built-in method inside NIntegrate, which can be accessed through IntegrationMonitor:

Reap[
Quiet@NIntegrate[Exp[-x]*Sin[x], {x, 0, ∞},
MaxRecursion -> 0,
Method -> {"SymbolicPreprocessing", "UnitCubeRescaling" -> True},
IntegrationMonitor -> (Sow[
First@Map[(#1@"Integrand")["FunctionExpression"] &, #1]] &)]
][[2, 1, 1]]
(*  -((E^(1 - 1/(1 - x)) Sin[1 - 1/(1 - x)])/(1 - x)^2)  *)


You can also search the tutorial NIntegrate Integration Strategies for FRangesToCube for code that does the transformation.