I'm attempting to calculate the gradient of a function defined by two variables. After following a tutorial I found, I have the following code:
f[x_, y_] = (2 x^4 - x^2 + 3 x - 7 y + 1)/(e^(2 x^2/3 + 3 y^2/4));
(*t is gradient of f*)
t[{x_, y_}] := {
D[f[x, y], x],
D[f[x, y], y]
};
(*
Trying to use NestList to basically calculate gradient descent 'n' times/
use Euler's method starting at the point (.510, -.445)
*)
NestList[t, {.51, -.445}, n]
However, the output I'm getting is ".51" and "-.445" are not valid variables. I understand this is because I when I apply NestList, I am essentially taking the derivative with respect to ".51" and "-.445" which isn't possible obviously. However, I am unsure of how to apply NestList with respect to the variables x and y at the point (.51,-.445).
ClearAll[t];t[{x_, y_}] = {D[f[x, y], x], D[f[x, y], y]};n = 3; NestList[t, {.51, -.445}, n]
? $\endgroup$ClearAll[t2];t2[{x_, y_}] = Grad[f[x, y], {x, y}];n = 3;NestList[t2, {.51, -.445}, n]
? $\endgroup$ClearAll[t3];t3[{x_, y_}] := Evaluate[{D[f[x, y], x], D[f[x, y], y]}]; n = 3;NestList[t3, {.51, -.445}, n]
$\endgroup$