I want to define a function that contains other functions but with other variables. Is it possible?

For example, I would like to do something like this:

A[x_, y_] = 2 x + y;

Now, some calculations on A, derivatives, and later:

B[a_, b_] = A[x,y]/.{x -> a Cos[b], y -> a Sin[b]}.
  • 1
    $\begingroup$ Use := instead of = while defining the functions. $\endgroup$
    – Syed
    Mar 1 at 14:00
  • $\begingroup$ Thanks, in this case, it works. But, generally, is this possible, when I cannot use := at the beginning? Generally, I am working with Eigensystems, so my first assignment, as I read, must be: A[x_,y_] = Eigenvalues[...][[1]]; $\endgroup$
    – blahblah
    Mar 1 at 14:05
  • 4
    $\begingroup$ You may directly define: B[a_, b_] = A[ a Cos[b], a Sin[b]] $\endgroup$ Mar 1 at 14:09
  • 1
    $\begingroup$ Please improve the question by including a minimal example so that you receive an applicable answer. $\endgroup$
    – Syed
    Mar 1 at 14:20
  • $\begingroup$ Along the lines of @DanielHuber, B[f_][a_,b]:= f[a_,b_] (e.g., B[ArcTan][1,1] $\endgroup$ Mar 1 at 17:11


Your Answer

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

Browse other questions tagged or ask your own question.