I have an expression which is a sum of undefined function v[n1,n2,n3,n4]
with 4 arguments (n_i
are integers):
expr=a*v[n1, n2, n3, n4] + b*v[n5, n6, n7, n8] + c*v[n9, n10, n11, n12] + ....
Now I increase or decrease the i
-th argument of v
in expr
, and also multiply each term with the value of v[[i]]
.
For example:
example=v[1,1,1,1]+10*v[0,0,2,0]
inc[example,3] (* first argument is the expression, second argument is the index of v that should be increased *)
(*
example -> example=v[[3]]*v[1,1,1+1,1]+10*v[[3]]*v[0,0,2+1,0]
-> example=1*v[1,1,2,1]+10*2*v[0,0,3,0]
*)
In reality, my v
has much more terms, therefore hardcoding inc
for each index is not feasible. I think I know how to do it with an ugly For
loop, but I hope that there is some clever Mathematica-style way.