       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:= expr=Expand[5 a +  3 b + (2 c + 5 a) / 7]

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

In:= FullForm[expr]

Out//FullForm=

>   Plus[Times[Rational[40, 7], a], Times[3, b], Times[Rational[2, 7], c]]

In:= Length[expr]

Out= 3

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

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

40     2
Out= {--, 3, -}
7      7

or better:

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

40               2
Out= {{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?