# Making a function definition where the right hand side is evaluated before the definition is saved [closed]

My question is about assigning the resulting expression after evaluation of a function.

So what I want:

FOCf[x, y] := D[f[x, y], x]


such it immediately evaluates the right hand side, making it a conditional expression.

How I do it now.

I first shift-enter: D[f[x, y], x]. Then, I manually copy the resulting output to the right end of FOCf[x, y] :=.

Is there a better way to do this? I already tried using Evaluate, but that did not seem to work.

• Is f defined prior to defining FOCf? – Edmund Feb 28 '19 at 22:20
• Not sure how to interpret your question. You can evaluate in place with [Ctrl] + [Shift] + [Enter], or you can use = (without the colon) to first evaluate the r.h.s. and then assign the result to the l.h.s. symbol. Btw., normally you indicate variables with an underscore on the left side, e.g. FOCf[x_, y_]. – JEM_Mosig Feb 28 '19 at 22:23
• Yes,f[x_, y_] := "conditional expression" before. I can also plot that one, so that seems fine. – Dick Oosthuizen Feb 28 '19 at 22:24
• Thank you, I didn't know about the = . – Dick Oosthuizen Feb 28 '19 at 22:28
• or you can write FOCf[x, y] := Evaluate @ D[f[x, y], x] – m_goldberg Mar 1 '19 at 7:07