1
$\begingroup$

I have defined a function

f[x_, y_, z_] := x*y^2 - y *z^2

and I want to evaluate its gradient at the point (0,-2,1) I tried Grad[f[x,y,z], {0,-2,1}] and that just gave me back the function with a nabla in front of it. I tried Grad[f[0, -2, 1], {x, y, z}]. That of course gives zero because x,y and z are constant, right?

$\endgroup$
5
$\begingroup$
f[x_, y_, z_] := x*y^2 - y*z^2

Grad[f[x, y, z], {x, y, z}] 

{y^2, 2 x y - z^2, -2 y z}

%/. {x -> 0, y -> -2, z -> 1}

{4, -1, 4}

$\endgroup$
2
$\begingroup$

Or you could make a second function

f[x_, y_, z_] := x*y^2 - y*z^2

gradf[x_, y_, z_] = Grad[f[x, y, z], {x, y, z}];

gradf[0, -2, 1]
(*{4, -1, 4}*)
$\endgroup$
0
$\begingroup$

You could also use Derivative:

Derivative[##][f][0, -2, 1] & @@@ IdentityMatrix[3]

$\left\{f^{(1,0,0)}(0,-2,1),\,f^{(0,1,0) }(0,-2,1),\,f^{(0,0,1)}(0,-2,1)\right \}$

In your specific case:

f[x_, y_, z_] := x*y^2 - y*z^2    
Derivative[##][f][0, -2, 1] & @@@ IdentityMatrix[3]

{4, -1, 4}

$\endgroup$

Your Answer

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

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