Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Collecting terms in an expression' topicStudent Support Forum > General > Archives > "Collecting terms in an expression"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
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: ,

Subject (listing for 'Collecting terms in an expression')
Author Date Posted
Collecting terms in an expression Sami 09/02/12 3:01pm
Re: Collecting terms in an expression Bill Simpson 09/03/12 11:34pm
Re: Re: Collecting terms in an expression Sami 09/04/12 12:48pm
Re: Re: Re: Collecting terms in an expression Bill Simpson 09/04/12 10:29pm
Re: Re: Re: Re: Collecting terms in an expression Sami 09/06/12 00:45am
Re: Re: Re: Re: Re: Collecting terms in an expr... Bill Simpson 09/06/12 11:36am
Re: Re: Re: Re: Collecting terms in an expression Sami 09/06/12 01:14am
Re: Re: Re: Re: Re: Collecting terms in an expr... Bill Simpson 09/07/12 2:57pm
Re: Re: Re: Re: Re: Re: Collecting terms in an ... Sami 09/08/12 03:26am
Re: Re: Re: Re: Re: Re: Re: Collecting terms in... Sami 09/11/12 8:12pm
Re: Re: Re: Re: Re: Re: Re: Re: Collecting term... Bill Simpson 09/14/12 03:31am
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic