I am trying to put all my functions in a single package and some of them do not work because of differentiation. Suppose I have the following package
BeginPackage["Diff`"]
Diff[yy_]:=Module[{cc},cc=D[yy,x[1]];cc];
End[]
EndPackage[]
And suppose I do the following
<<Diff`
Diff[x[1]^2]
I expect to get 2x[1], but I get 0, what is going on? Probably I am missing something very simple. And yes I need variables in the form x[1],x[2],..., not x,y,z. Interestingly everything works perfectly fine if I do it without packaging:
Diff[yy_]:=Module[{cc},cc=D[yy,x[1]];cc];
Diff[x[1]^2]
The last operation gives 2x[1].
Dif[yy_, xx_] := Module[{cc}, cc = D[yy, xx]; cc];and thenDif[x[1]^2, x[1]]? – Dr. belisarius Aug 03 '15 at 03:482 x[1], not0. Is what you've written your actual package code? If you are actually puttingDiffin aPrivatecontext, then you would get0. – Simon Rochester Aug 03 '15 at 05:04