I want to find out the coefficients and functions from an expression and possibly save them in separate files with same order.
I have the following toy example:
func = A1*x[1,0,0] + A2*x[1,0,1] + A3*x[1,1,1] + B1*x[1,0,0] + B2*x[1,0,1] + B3*x[1,1,1];
A priori I don't know the different forms of the functions
x but I know it has fixed number of arguments in this case three arguments and there could be repetative
Collect I can group repetative
x. However how should I separate them in a file, in the most general way i.e. not knowing the explicit arguments of
In:= Collect[func,x[y1_,y2_,y3_]] Out:= (A1 + B1)*x[1, 0, 0] + (A2 + B2)*x[1, 0, 1] + (A3 + B3)*x[1, 1, 1]
The final output would be two files, one containing the coefficients
(A1+B1), (A2+B2), (A3+B3) and the other with corresponding functions
x[1,0,0], x[1,0,1], x[1,1,1] in the same orders may be in a single column.