MathGroup Archive 2006

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

Search the Archive

Re: efficient term collection algorithm


Thank you everyone for your helpful responses. Many of you suggested
using Collect, which works very well for this problem!

I used David Park's algorithm, adding one modification--I sorted the
list of denominators in decreasing length. This modification prevents
undesirable behavior when denominators contains terms like i and i(i+1)

collectDenominators[expr_, func_] := Module[{answer, work =
Expand[expr],
    factors}, factors = Union[Denominator /@ List @@ work];

      factors = Sort[factors, Length[#1] > Length[#2] &]^-1;

      answer = Collect[expr, factors, func];

      answer
      ];

Apart works well for the simple example I gave, but for some reason
does not combine fractions in my actual problem which share a common
denominator (perhaps due to the complexity of the numerators?). I have
found Apart very useful in a closely related probelm, however, so thank
you for bringing that function to my attention.

Blake Laing
physics graduate student
University of Oklahoma


  • Prev by Date: Re: [TS 22578]--Re:does anyone have an ant task for mathematica?
  • Next by Date: Re: Exporting text to (or in) vector graphics as "sentences"?
  • Previous by thread: Re: efficient term collection algorithm
  • Next by thread: Re: efficient term collection algorithm