6
$\begingroup$

I have a list of functions (actually they are derivatives) of the type:

{D[g[x,y],x],D[g[x,y],y]}

I would like to evaluate all of these functions at a point, say,[0,0], creating a list of the type:

{D[g[x,y],x][0,0],D[g[x,y],y][0,0]}

Is this possible? Thanks.

$\endgroup$
1
  • $\begingroup$ are you sure you want D[g[x,y],x][0,0]? $\endgroup$
    – Kuba
    Commented Jan 29, 2015 at 17:16

2 Answers 2

8
$\begingroup$

To get what you asked for, you can use

dl = {D[g[x, y], x], D[g[x, y], y]};
Through @ dl[0, 0]

enter image description here

However, as noted by @Kuba, you probably want something like

ClearAll[foo];
foo = Through@(Function[{x, y}, #] & /@ dl)@## &;
foo[0, 0] 

enter image description here

$\endgroup$
2
  • $\begingroup$ Thats exactly it. Thanks. $\endgroup$
    – user191919
    Commented Jan 29, 2015 at 17:17
  • $\begingroup$ @user191919, my pleasure.. $\endgroup$
    – kglr
    Commented Jan 29, 2015 at 17:20
1
$\begingroup$
f[x_] := x^2;
g[x_] := x^3;

{f[#], g[#]} & @ 5

(* {25, 125} *)

Or for your example:

f[x_, y_] := x^2 + y;
g[x_, y_] := Sin[x] + y^3;

{D[f[x, y], x], D[g[x, y], y]} /. {x -> 3, y -> 4}

(* {6, 48} *)

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.