
Re: How do you control evaluation when using apply?
Posted:
May 17, 2013 4:33 AM


Hello,
both of your versions work fine in M9.
Here is even a shorter one:
In[]:= jacFun[func_, vars_] := Module[{f}, f = Function @@ {{x, y}, D[func, {vars}]}; f @@ # &]
In[]:=jacFun[{Sin[x y], Cos[x + y]}, {x, y}][{10, 2}]
Out[]:={{2 Cos[20], 10 Cos[20]}, {Sin[12], Sin[12]}}
BR,
Christoph
On 05/16/2013 09:28 AM, Brentt wrote: > Why does this work > > In[0]: = jacobianFunction[func_, vars_List] := Module[{f}, > f = Function[Evaluate[vars], Evaluate[D[func, {vars}]]]; > f > ]; > jacobianFunction[{Sin[x y], Cos[x + y]}, {x, y}] @@ {10, 2} > > out[0]:= {{2 Cos[20], 10 Cos[20]}, {Sin[12], Sin[12]}} > > But this does not (the goal is to make the function take a point as an > argument) > > > In[0]: = jacobianFunction[func_, vars_List] := Module[{f}, > f = Evaluate[Function[Evaluate[vars], Evaluate[D[func, {vars}]]]]; > f@@ # & > ]; > jacobianFunction[{Sin[x y], Cos[x + y]}, {x, y}][{10, 2}] > > > > I can't get f@@ # & to evaluate properly (I've tried wrapping it in > ReleaseHold and evaluate statements, nothing seems to get it to evaluate. > > I know I can just rewrite the function to take the point but I'm just > curious why it won't work. > >

