Does anyone see what I am doing wrong here? I am trying to automate this:
Clear[g, g1, g2];
g[x_?NumericQ, y_?NumericQ, z_?NumericQ] := (c += 1; x y z + x^2 y^2 z)
g1[x_?NumericQ, y_?NumericQ, z_?NumericQ] := ND[g[x1, y, z], x1, x]
g2[x_?NumericQ, y_?NumericQ, z_?NumericQ] := ND[g1[x, y1, z], y1, y]
ND[g2[1, 1, z], z, 1] // N
Here's my code:
ClearAll[h,temp,x,y,z];
SetAttributes[nd,HoldFirst];
nd[f_[v1__],v2__]:=Module[{
indexes=Range[Length@{v1}],
lhs=DownValues[f],
rhs=Hold@DownValues[f][[1,2]],