MathGroup Archive 1999

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

Search the Archive

Re: Coefficients in expressions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16813] Re: [mg16742] Coefficients in expressions
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Tue, 30 Mar 1999 02:35:16 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

I am not quite sure if I have understood what you want correctly. But the
following definition might do what you want:

In[1]:=
coeffs[Equal[x_,y_],z_List]:=Coefficient[x,z]-Coefficient[y,z];
SetAttributes[coeffs,HoldFirst];

Now, for example:

In[2]:=
coeffs[3x+2y==4x+5z+3,{x,y,z}]
Out[2]=
{-1,2,-5}

The problem I have with your question is that you did  not make clear how
you want the coefficients  of the variables on the left and right hand
sides of your equation to be treated. The only sensible way seems to me 
to treat the coefficients on the left as positive and on the right as
negative (or conversly !). Of course the lists of coefficients of
equivalent equations will, in general, differ by a scalar factor (they
can be viewed as so called "projective coordinates"): 

In[3]:=
coeffs[x+y==z,{x,y,z}]
Out[3]=
{1,1,-1}

In[4]:=
coeffs[2z==2x+2y,{x,y,z}]
Out[4]=
{-2,-2,2}





On Wed, Mar 24, 1999, Virgil Stokes <virgil.stokes at neuro.ki.se> wrote:

>I have generated several expressions (equations) in the form of:
>
>   c1*x1 + c2*x1' + c3*x2 + c4*y1+...+a1*x1'+ a2*y1 + a5*x1 +... ==
f1*z1 +...
>
>where, the equations can be over 50 lines in length.
>I would like to have a procedure (say Coeffs[.]) that would
>allow me to specify as input the "names" in the equations. The
>output would be all the coefficients for that list of names.
>For example, for the above,
>
>  Coeffs[%,x1,x1',y1]
>
>would output,
>
>    x1: (c1+a5)
> x1': (c2+a1)
>  y1: (c4+a2)
>
>-- V. Stokes
>
>


Andrzej Kozlowski
Toyama International University
JAPAN
http://sigma.tuins.ac.jp/
http://eri2.tuins.ac.jp/



  • Prev by Date: Re: Solving propagation problems?
  • Next by Date: Mathlink : Problem in debugging from VC++.
  • Previous by thread: Coefficients in expressions
  • Next by thread: Re: Coefficients in expressions