MathGroup Archive 2006

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

Search the Archive

RE: efficient term collection algorithm

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69190] RE: [mg69155] efficient term collection algorithm
  • From: "David Park" <djmp at earthlink.net>
  • Date: Fri, 1 Sep 2006 06:41:31 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Blake,

What about trying to extract the denominators and then using the Mathematica
Collect routine?

collectDenominators[expr_] :=
  Module[{work = Expand[expr], factors},
    factors = Union[Denominator /@ List @@ work]^-1;
    Collect[expr, factors]
    ]

collectDenominators[(b*i + a*j + c*j)/(i*j)]
(a + c)/i + b/j

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/


From: Blake Laing [mailto:laing at nhn.ou.edu]
To: mathgroup at smc.vnet.net

Dear Math Group

I wish to combine terms in a expression which share a denominator, such
as in the following simple case:

In[1]:=
a/i+b/j+c/i//.Plus[Times[A_.,Power[denom_,-1]],Times[B_.,Power[denom_,-1]]]:
>
      Factor[Plus[A,B]Power[denom,-1]]//InputForm
Out[1]//InputForm=
(a + c)/i + b/j

The actual expression I am working with contains thousands of terms, and
a pairwise algorithm such as this is wholly inadequate. Will one of you
please suggest a more efficient way to combine each additive term in a
large expression with a shared denominator?

Thanks,

Blake Laing
physics grad student
University of Oklahoma




  • Prev by Date: Re: efficient term collection algorithm
  • Next by Date: Re: generalized foldlist problem - part 2
  • Previous by thread: Re: efficient term collection algorithm
  • Next by thread: Re: efficient term collection algorithm