Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Collect coefficients of array variables during calculation:

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87027] Re: Collect coefficients of array variables during calculation:
  • From: Peter Pein <petsie at dordos.net>
  • Date: Sat, 29 Mar 2008 04:24:36 -0500 (EST)
  • References: <fsib0m$5qe$1@smc.vnet.net>

Gopinath Venkatesan schrieb:
> Hello Mathematica Friends
> 
> If we have an array variable, and assuming after intermediate calculations, some equations are found to be below.
> 
> eqn1=10. A[[1,1]]+b A[[1,1]]+c A[[1,2]]+3. A[[1,2]] (only for illustration)
> 
> Simplify[] does not combine the coefficients under same array member, i.e. instead of (10.+b)A[[1,1]]+(c+3.)A[[1,2]], it is showing the earlier mentioned form.
> 
> Is there a way to collect them and simplify them. But when I checked for simple cases, Simplify[] seems to work.
> 
> Thanks for the suggestions.
> 
> Regards,
> Gopinath
> University of Oklahoma
> 

Hi Gopinath,

use Collect[] to collect ;-)

In[2]:=
Collect[eqn1,_Part]
Out[2]=
(10. + b)*A[[1,1]] + (3. + c)*
    A[[1,2]]

you can give a function as third parameter which is applied to the 
coefficients:
In[3]:=
Collect[eqn1, _Part, Rationalize]
Out[3]=
(10 + b)*A[[1,1]] + (3 + c)*A[[1,2]]


hth,
Peter


  • Prev by Date: Re: Collect coefficients of array variables during
  • Next by Date: Re: submission of a new problem; NDSolve artifacts; version 6.0.1
  • Previous by thread: Re: Collect coefficients of array variables during calculation:
  • Next by thread: Re: Collect coefficients of array variables during calculation: