Re: automatic coefficient / summand extraction

• To: mathgroup at yoda.physics.unc.edu
• Subject: Re: automatic coefficient / summand extraction
• From: sergio at shark.inst.bnl.gov (Sergio Rescia)
• Date: Thu, 21 Oct 93 15:09:56 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 -----

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

```

• Prev by Date: Re: Matrix Operations in Mma
• Next by Date: Re: automatic coefficient / summand extraction
• Previous by thread: automatic coefficient / summand extraction
• Next by thread: Re: automatic coefficient / summand extraction