Force function evaluation on declaration

夙愿已清 提交于 2019-12-02 03:03:05

An alternative to Mr Wizard's solution is that you can also put the Evaluate in the function's definition:

f[x_, y_, z_] := Evaluate[Limit[Multinomial[x, y, z], x->0]]

Plot3D[f[x, y, z], {y, 1, 5}, {z, 1, 5}]

You can compare the two versions with the one without an Evaluate by Timing the Plot.

The function you need is logically called Evaluate and you can use it within the Plot command.

Here is a contrived example:

f[x_, y_, z_] := Limit[Multinomial[x, y, z], x -> 0]

Plot3D[ Evaluate[ f[x, y, z] ], {y, 1, 5}, {z, 1, 5}]

Addressing your follow-up question, perhaps all you seek is something like

ff = f[x, y, z]

Plot3D[ff, {y, 1, 5}, {z, 1, 5}]

or possibly merely

ClearAll[f, x, y, z]

f[x_, y_, z_] = Limit[Multinomial[x, y, z], x -> 0]

Plot3D[f[x, y, z], {y, 1, 5}, {z, 1, 5}]

It would be helpful if you would post a more complete version of your code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!