# How can I change the dependent variables of a function?

What I want is to define a function which depends of some variables and then get the expression for that same function when it depends of different variables.

My specific case is: (where u is the main function and u0 is a part of it.)

u[x_, y_, z_] = ((-I)*Integrate[E^(((I/2)*k*((x - x0)^2 + (y - y0)^2))/z)*u0[x0, y0], y0, {x0, -Infinity, Infinity}])/(z*\[Lambda])

u0[x, y] = P[x, y] Exp[(-I k)/(2 f ) (x^2 + y^2)]


And now I want to know how the function changes with the variables: u[r_, zR_], where:

 r = Sqrt[x^2 + y^2];
zR = z - f;


What I need is a code where I write u[variables] and it gives me the main function but with the new variables.

• I think you might want to call your changed-variable version of the function something other than u, otherwise Mathematica (and maybe the person reading this question) would have no way to distinguish them! – thorimur Apr 7 at 20:02
• For example, you might want to say you want v such that v[Sqrt[x^2 + y^2], z - f] == u[x, y, z]. – thorimur Apr 7 at 20:04
• Note that your function definitions are also a bit off: they should be of the form f[x_, y_, ...] = , not f[x, y, ...] =. – thorimur Apr 7 at 20:11
• Are you sure? The analogy to what I'm saying would be: original function: g[y_] := y^6, new variable: q = y^2, and we want a new version of g, g2, which is "in terms of this variable", i.e. g2[q] == g[y] and therefore g2[y^2] == g[y], so we could take g2[q_] := q^3. – thorimur Apr 7 at 21:10
• Also, note that you can write code by enclosing text in backticks like this! – thorimur Apr 7 at 21:11

Is this what you want:

ClearAll[r, zR];
r: = Sqrt[x^2 + y^2];
zR: = z - f;
u0[x_, y_] := PP[x, y] Exp[(-I k)/(2 f) (x^2 + y^2)]
u1[x_, y_,z_] := ((-I)*
Integrate[E^(((I/2)*k*((x - x0)^2 + (y - y0)^2))/z)*u0[x0, y0],
y0, {x0, -Infinity, Infinity}])/(z*\[Lambda])


You should run:

u1[r, zR, z0] /. z -> z0