I am trying to set to zero some expression in a very long summation in mathematica. So I have decided to use a do loop along with a the replace operator over all indices I want to remove (actually indices such as [-i, 0], [0,0] and [i, 0]).
Do[
Cor = Cor /. {q[i, 0] -> 0}
, {i, 0, ndof1}]
Cor
with Cor is something like
Cor = - Sum[ (eps[j, k]*q[j, k] +
q[j, k]*abs (q[j, k])^(sig) -
w*(q[j - 1, k] + q[j + 1, k] + q[j, k - 1] + q[j, k + 1]) )^2
, {j, 0, ndof1}, {k , 0, ndof2}]
As a result, I am getting something with
/. 0 /. 0 /. 0 /. 0 /. 0 /. 0 /. 0 /. 0 /. 0 /. 0 /. 0
at the end on which I can't perform further operation like derivative for instance.
Please can someone help. I am struggling with this problem in many of my codes so that I get a proper expression at the end.
q
likeDo[q[i,0]=0, {i, 0, ndof1}]
? and then evaluateCor
? $\endgroup$rep = Table[q[i, 0] -> 0, {i, 0, n1}]
and thencor /. rep
$\endgroup$