In[]:=
x={x1,x2,x3};​​expr=Inactive[Sum][D[p[k][x1,x3,x3],x[[k]]],{k,1,3}]
Part
:The expression k cannot be used as a part specification.
Out[]=
3
∑
k=1
0
In[]:=
Inactive[Sum][Inactive[D][p[k][x1,x2,x3],x[[k]]],{k,1,3}]
Part
:The expression k cannot be used as a part specification.
Out[]=
3
∑
k=1
∂
{x1,x2,x3}〚k〛
p[k][x1,x2,x3]
In[]:=
expr=Inactive[Sum][Inactive[D][p[k]@@x,x[[k]]],{k,1,Length[x]}];​​
Part
:The expression k cannot be used as a part specification.
In[]:=
ClearAll[x1,x2,x3,p,x,k]​​​​x={x1,x2,x3};​​​​expr=Inactive[Sum][Inactive[D][p[k]@@x,(*function*)Inactive[Part][x,k]],(*∂/∂x_kkeptinert*){k,1,3}];
In[]:=
expr
Out[]=
3
∑
k=1
∂
{x1,x2,x3}〚k〛
p[k][x1,x2,x3]
In[]:=
Activate[expr]
Out[]=
(0,0,1)
p[3]
[x1,x2,x3]+
(0,1,0)
p[2]
[x1,x2,x3]+
(1,0,0)
p[1]
[x1,x2,x3]
In[]:=
func[p_]:=Inactive[Sum][Inactive[D][p[k],(*function*)Inactive[Part][x,k]],(*∂/∂x_kkeptinert*){k,1,3}];​​func[Function[i,p[i]@@x]]==expr
Out[]=
True
func[p_]:=Inactive[Sum][Inactive[D][p[k],(*function*)Inactive[Part][x,k]],(*∂/∂x_kkeptinert*){k,1,3}];
In[]:=
D[func[Function[i,p[i]@@x+ϵψ@@xKroneckerDelta[k,1]]],ϵ]//InputForm
Out[]//InputForm=
Inactive[Sum][KroneckerDelta[1, k]*ψ[x1, x2, x3]*Inactive[D][1, Inactive[Part][{x1, x2, x3}, k]], {k, 1, 3}]
In[]:=
Derivative[Sequence@@UnitVector[3,j]][p@@x]
Out[]=
(3,j)
p[x1,x2,x3]
In[]:=
UnitVector[3,1]
Out[]=
{1,0,0}
func2[p_]:=Inactive[Sum][Derivative[UnitVecto][p[k]],(*∂/∂x_kkeptinert*){k,1,3}];​​func2[Function[i,p[i]@@x]]
Out[]=
3
∑
k=1
(1,0,0)
p[k][x1,x2,x3]
In[]:=
expr1=Limit[(func[Function[i,p[i]@@x+ϵψ[i]@@xKroneckerDelta[i,j]]]-func[Function[i,p[i]@@x]])/ϵ,ϵ->0]//Activate
Out[]=
(0,0,1)
ψ[3]
[x1,x2,x3]
j3
(0,1,0)
ψ[2]
[x1,x2,x3]
j2
(1,0,0)
ψ[1]
[x1,x2,x3]
j1
0
True
In[]:=
expr1//InputForm
Out[]//InputForm=
Inactive[Sum][KroneckerDelta[j, k]*Inactive[D][1,
Inactive[Part][{x1, x2, x3}, k]]*ψ[k][x1, x2, x3], {k, 1, 3}]
​
Inactive[Sum][KroneckerDelta[j,k]*Inactive[D][1,​​Inactive[Part][{x1,x2,x3},k]]*ψ[k][x1,x2,x3],{k,1,3}]
​
In[]:=
func[p_]:=Inactive[Sum][Inactive[D][p[k],(*function*)Inactive[Part][x,k]],(*∂/∂x_kkeptinert*){k,1,3}];​​D[func[Function[i,(ϵψ[i][x1,x2,x3]KroneckerDelta[i,j])]],ϵ]//InputForm
Out[]//InputForm=
Inactive[Sum][KroneckerDelta[j, k]*Inactive[D][1, Inactive[Part][{x1, x2, x3}, k]]*ψ[k][x1, x2, x3], {k, 1, 3}]
In[]:=
expr1=Limit[(func[Function[i,p[i]@@x+ϵψ[i]@@xKroneckerDelta[i,j]]]-func[Function[i,p[i]@@x]])/ϵ,ϵ->0]//Activate//InputForm
Out[]//InputForm=
Piecewise[{{Derivative[0, 0, 1][ψ[3]][x1, x2, x3], j == 3}, {Derivative[0, 1, 0][ψ[2]][x1, x2, x3], j == 2}, {Derivative[1, 0, 0][ψ[1]][x1, x2, x3], j == 1}}, 0]
In[]:=
D[func[Function[i,p[i]@@x+ϵψ[i]@@xKroneckerDelta[k,1]]],ϵ]//InputForm
Out[]//InputForm=
Inactive[Sum][KroneckerDelta[1, k]*Inactive[D][1, Inactive[Part][{x1, x2, x3}, k]]*ψ[k][x1, x2, x3], {k, 1, 3}]
In[]:=
Inactive[Sum][KroneckerDelta[j,k]*Inactive[D][ψ[k][x1,x2,x3],Inactive[Part][{x1,x2,x3},k]],{k,1,3}]//Activate
Out[]=
δ
3,j
(0,0,1)
ψ[3]
[x1,x2,x3]+
δ
2,j
(0,1,0)
ψ[2]
[x1,x2,x3]+
δ
1,j
(1,0,0)
ψ[1]
[x1,x2,x3]
In[]:=
(*callit∂ifyoulike*)​​SetAttributes[∂,HoldAll];​​​​(*∂_if(x)=Inactive[D][f,x_i]withx_ikeptinert*)​​∂[i_][expr_]:=Inactive[D][expr,Inactive[Part][x,i]]
Derivative
:∂,HoldAll cannot be interpreted. A partial derivative requires a subscript differentiation variable.
In[]:=
∂[i_][expr_]:=Inactive[D][expr,Inactive[Part][x,i]]
Derivative
:∂[i_][expr_] cannot be interpreted. A partial derivative requires a subscript differentiation variable.
In[]:=
SetAttributes[partial,HoldAll];
In[]:=
partial[i_][expr_]:=Inactive[D][expr,Inactive[Part][x,i]]
In[]:=
partial[i_]/:D[partial[i_][expr_],ε_Symbol]:=partial[i][D[expr,ε]]
TagSetDelayed
:Argument partial[i_] at position 1 is expected to be a symbol.
Out[]=
partial[i_]/:
∂
ε_Symbol
partial[i_][expr_]:=partial[i][
∂
ε
expr]
In[]:=
func[p_]:=Inactive[Sum][∂[k][p[k]],{k,1,3}]​​
Derivative
:∂[k][p[k]] cannot be interpreted. A partial derivative requires a subscript differentiation variable.
In[]:=
learAll[PD,coords,k,j,ε,Ψ,p];​​​​coords={x1,x2,x3};(*thecoordinatevectorx*)​​​​(*Inert“∂/∂x_i”--------------------------------------------------*)​​SetAttributes[PD,HoldAll];​​​​PD[i_Integer][expr_]:=Inactive[D][expr,Inactive[Part][coords,i]](*keepD&Partinert*)​​​​(*HowPDcommuteswithanexternalderivatived/dε-----------------*)​​PD/:D[PD[i_][expr_],ε_Symbol]:=PD[i][D[expr,ε]]
In[]:=
Format[PD[i_]]:=Subscript[∂,i](*purelycosmetic*)
Derivative
:∂,i cannot be interpreted. A partial derivative requires a subscript differentiation variable.
In[]:=
func[f_]:=Inactive[Sum][PD[k][f[k]],{k,1,Length[coords]}];
In[]:=
expr=func[Function[i,εΨ[i]@@xKroneckerDelta[i,j]]]
Out[]=
3
∑
k=1
PD[k]ε
δ
j,k
Ψ[k][x1,x2,x3]
In[]:=
dexpr=D[expr,ε]//InputForm
Out[]//InputForm=
Inactive[Sum][KroneckerDelta[j, k]*Ψ[k][x1, x2, x3]*Derivative[1][PD[k]][ε*KroneckerDelta[j, k]*Ψ[k][x1, x2, x3]], {k, 1, 3}]
In[]:=
ClearAll[coords,PD,k,j,ε,Ψ,p];​​coords={x1,x2,x3};(*coordinatevectorx*)​​​​SetAttributes[PD,HoldAll];(*do**not**evaluateitsargument*)​​​​(*PD[i][expr]isan*inert*∂/∂x_iactingonexpr*)​​PD[i_Integer][expr_]:=Inactive[D][expr,Inactive[Part][coords,i]];
In[]:=
(*d/dε(PD_iexpr):=PD_i(dexpr/dε)*)PD/:D[PD[i_][expr_],var_Symbol]:=PD[i][D[expr,var]];
In[]:=
ClearAll[func];​​SetAttributes[func,HoldAll];​​​​func[f_]:=Inactive[Sum][PD[k][f[k]],{k,1,Length[coords]}];
In[]:=
expr=func[Function[i,εΨ[i][Sequence@@coords]KroneckerDelta[i,j]]];​​​​dexpr=D[expr,ε];(*<--THISiswhatgaveyoutheerrorbefore*)
In[]:=
dexpr//InputForm
Out[]//InputForm=
Inactive[Sum][KroneckerDelta[j, k]*Ψ[k][x1, x2, x3]*Derivative[1][PD[k]][ε*KroneckerDelta[j, k]*Ψ[k][x1, x2, x3]], {k, 1, 3}]