Say I have an expansion of terms containing functions y[j,t] and its derivatives, indexed by j with the index beginning at 0 whose independent variable are t, like so:
Expr = y[0,t]^2 + D[y[0,t],t]*y[0,t] + y[0,t]*y[1,t] + y[0,t]*D[y[1,t],t] + (y[1,t])^2*y[0,t] + ... etc.
Now I wish to define new functions indexed by i, call them A[i], that collect all terms from the expression above such that the sum of the indices of the factors in each term sums to i.
In the above case for the terms shown we would have for example
A[0] = y[0,t]^2 + D[y[0,t],t]*y[0,t]
A[1] = y[0,t]*y[1,t] + y[0,t]*D[y[1,t],t]
A[2] = (y[1,t])^2*y[0,t]
How can I get mathematica to assign these terms to these new functions automatically for all i?
Note: If there is a better way to be indexing functions also feel free to suggest.


y[0,t_] = 1+2tand then I recall the above elements of the list, the derivativeDerivative[0, 1][y][0, t]will not evaluate with the new definition, it is left in its general form. How can I ensure that they are evaluated once the element of the list is called after I have defined y[0,t]? – Decebalus Jul 10 '19 at 20:48yto be an explicit function, this will break the routine that sorts the terms. I suggest, instead of locking in a definition, to use a substitution instead, whenever needed:/. y :> (If[#1 === 0, 1 + 2 #2, y[#1, #2]] &)-- This substitutes a function for eachywhere#2is the second argument of this function whenever the first argument#1is equal to0. – Kagaratsch Jul 10 '19 at 21:33