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.

  • $\begingroup$ 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! $\endgroup$
    – thorimur
    Apr 7, 2021 at 20:02
  • $\begingroup$ For example, you might want to say you want v such that v[Sqrt[x^2 + y^2], z - f] == u[x, y, z]. $\endgroup$
    – thorimur
    Apr 7, 2021 at 20:04
  • $\begingroup$ Note that your function definitions are also a bit off: they should be of the form f[x_, y_, ...] = , not f[x, y, ...] =. $\endgroup$
    – thorimur
    Apr 7, 2021 at 20:11
  • 1
    $\begingroup$ 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. $\endgroup$
    – thorimur
    Apr 7, 2021 at 21:10
  • 1
    $\begingroup$ Also, note that you can write code by enclosing text in backticks `like this`! $\endgroup$
    – thorimur
    Apr 7, 2021 at 21:11

1 Answer 1


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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