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: [mg87064] Re: Collect coefficients of array variables during calculation:
  • From: Szabolcs Horvát <szhorvat at gmail.com>
  • Date: Sun, 30 Mar 2008 01:19:15 -0500 (EST)
  • Organization: University of Bergen
  • References: <fsib0m$5qe$1@smc.vnet.net>

Gopinath Venkatesan wrote:
> 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.

Actually Simplify[] does collect the terms without additional effort:

In[1]:= eqn1 =
  10. A[[1, 1]] + b A[[1, 1]] + c A[[1, 2]] + 3. A[[1, 2]]

During evaluation of In[1]:= Part::partd: Part specification A[[1,1]] \
is longer than depth of object. >>

During evaluation of In[1]:= Part::partd: Part specification A[[1,1]] \
is longer than depth of object. >>

During evaluation of In[1]:= Part::partd: Part specification A[[1,2]] \
is longer than depth of object. >>

During evaluation of In[1]:= General::stop: Further output of \
Part::partd will be suppressed during this calculation. >>

Out[1]= 10. A[[1, 1]] + b A[[1, 1]] + 3. A[[1, 2]] + c A[[1, 2]]

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

This still doesn't change the fact that this usage of Part ([[ ... ]]) 
is /incorrect/, though.


  • Prev by Date: Re: Number of monomials
  • Next by Date: Re: IsIntegerOrFloat
  • Previous by thread: Re: Collect coefficients of array variables during calculation:
  • Next by thread: Problem with FourierParameters