I'd like to control the order of evaluation in a multi-variable function. Example: Suppose I have the function:

B[x_, y_] := x + y/x;

If I try to evaluate B[0,0] I get Indeterminate although if I plug in the value of y first and then x I should get 0. Using an intermediate function is not possible in my case.

Is there any way to tell mathematica to plug in the value of y first, evaluate the function, then plug the value of x ?

  • 1
    $\begingroup$ To do what you literally asked: B[x_, y_] := Module[{xx, yy}, xx + yy/xx /. yy -> y /. xx -> x] $\endgroup$ – Bob Hanlon Nov 5 '19 at 0:07

Maybe easiest to give a definition for your special case, in addition to your general definition.

B[x_, y_] := x + y/x
B[0, 0] := 0
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy