I am trying to write a command to collapse the sum of terms into an expression with summation. Something like
F_[1, j___] + F_[2, j___] + F_[3, j___] := Sum[F[i, j], {i, 1, 3}]
which is designed to to collapse the LHS, which is a function of 2 or more parameters (for example - F[i,j] or F[i,j,k] - this is the reason for the i___ in the definition) into a summation on the first variable. but I get the following error:
SetDelayed::write: "Tag Plus in F_[1,i___]+F_[2,i___]+F_[3,i___] is Protected"
It seems that I am overriding the Plus definition. I don't know then how to define this properly. Thanks.
F_
) or only certain symbols? $\endgroup$ – mfvonh Jul 19 '14 at 21:08F[1,i]+F[2,i]+F[3,i]
wherei
would appear as the summation index and as an external variable. That doesn't look like a replacement I would want to make in general. The answer would probably useUpSetDelayed
, not unprotectingPlus
. $\endgroup$ – Jens Jul 19 '14 at 22:09