Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: efficient term collection algorithm

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69377] Re: efficient term collection algorithm
  • From: "Blake" <blakeandteresa at gmail.com>
  • Date: Sat, 9 Sep 2006 03:26:59 -0400 (EDT)
  • References: <ed68a7$jci$1@smc.vnet.net>

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