MathGroup Archive 1993

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: automatic coefficient / summand extraction

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Re: automatic coefficient / summand extraction
  • From: Sergio.Rescia.Phone:516-282-4232.FAX:516-282-5773 at shark.inst.bnl.gov
  • Date: Thu, 21 Oct 93 15:00:37 EDT

Dear Axel,

Here is one way.

First look at the "internal" form of your expression:

In[35]:= expr=Expand[5 a +  3 b + (2 c + 5 a) / 7]

         40 a         2 c
Out[35]= ---- + 3 b + ---
          7            7
Note terms are in alphabetical order.

In[36]:= FullForm[expr]

Out[36]//FullForm= 
 
>   Plus[Times[Rational[40, 7], a], Times[3, b], Times[Rational[2, 7], c]]

In[37]:= Length[expr]

Out[37]= 3

It is now clear that one simple way to have your coefficient list is:

In[38]:= Table[expr[[i,1]],{i,1,Length[expr]}]

          40     2
Out[38]= {--, 3, -}
          7      7

or better:

In[39]:= Table[{expr[[i,2]],expr[[i,1]]},{i,1,Length[expr]}]

              40               2
Out[39]= {{a, --}, {b, 3}, {c, -}}
              7                7

Regards,

Sergio


----- End Included Message -----






  • Prev by Date: Re: automatic coefficient / summand extraction
  • Next by Date: Re: Introduction
  • Previous by thread: Re: automatic coefficient / summand extraction
  • Next by thread: Student version of Mathematica?