Author 
Comment/Response 
Bill Simpson

09/07/12 2:57pm
In Response To 'Re: Re: Re: Re: Collecting terms in an expression'  In[1]:= expr=Exp[a Fx[1]^2+a Fy[1]^2+a Fz[1]^2+b Fx[2]^2+b Fy[2]^2+b Fz[2]^2+c Fx[3]^2+c Fy[3]^2+c Fz[3]^2];
In[2]:= expr//.((_[n_]^2)..)>f[n]^2//._Integer*f_[i_]^2>f[i]
Out[2]= E^(a*f[1] + b*f[2] + c*f[3])
There are other and perhaps even better ways of doing this, but there are always a dozen different ways of doing anything in Mathematica, at least several of which are completely incomprehensible.
You have a huge amount of work to do. You can start by reading all the help pages on pattern matching. That will almost certainly not be enough. Then get yourself a couple of good books on Mathematica and read the chapters on pattern matching over and over. "Mathematica Navigator" is a good book to study. Even the previous edition which is available used and cheap would be ok to learn pattern matching, but other parts of Mathematica have changed and you would have to know how to deal with that. "The Mathematica Cookbook" is newer and would be a good second book to study.
URL: , 
