Re: Together, Apart, ?
- To: mathgroup at smc.vnet.net
- Subject: [mg17002] Re: Together, Apart, ?
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Sat, 10 Apr 1999 02:13:36 -0400
- References: <7ehj7k$nsb@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Arnold, A quick attempt at a version of Together ClearAll["`*"] MyTogether[e___ + a_./b_ + c_./d_]:= MyTogether[e + MyTogether[a d + c b]/(b d)] MyTogether[e___ + a_+ c_./d_]:= MyTogether[e + MyTogether[a d + c]/d]; MyTogether[e_] := e Used in the usual way it will not go inside the obvious parts In[116]:= MyTogether[k/m+(a+b)/(c+d/g)+(e+f)/(g+h) + 1/p +q+1] Out[116]= (c*(g + h)*m*p + 1/g^2* (d*g*(g + h)*m*p + g*(d*(g + h)*m + c*g*(g + h)*m + g*((c + d/g)*(g + h)*k + ((e + f)*(c + d/g) + (a + b)*(g + h))*m)*p)) \ + (c + d/g)*(g + h)*m*p*q)/((c + d/g)*(g + h)*m*p) But with MapAll it will go right inside In[117]:= MyTogether//@(k/m+(a+b)/(c+d/g)+(e+f)/(g+h) + 1/p +q+1) Out[117]= (d*(g + h)*m + c*g*(g + h)*m + d*(g + h)*m*p + c*g*(g + h)*m*p + ((d + c*g)*(g + h)*k + ((e + f)*(d + c*g) + (a + b)*g*(g + h))*m)*p + (d + c*g)*(g + h)*m*p*q)/((d + c*g)*(g + h)*m*p) Allan -- --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 Arnold Gregory Civ AFRL/SNAT <Gregory.Arnold at sn.wpafb.af.mil> wrote in message news:7ehj7k$nsb at smc.vnet.net... > Hello: > > I'm still trying to figure out a 'good' way to manipulate some huge > expressions (on the order of 10M leaves)?. Based on recent suggestions, > I've been using Together instead of Simplify and this has helped > tremendously in many cases. However, even Together often chugs away for > days on my computer, and I think I have a clue why... it boils down to the > following examples: > > Together[(a+b)/(c+d)+(e+f)/(g+h)] // InputForm > Out[82]//InputForm= > (c*e + d*e + c*f + d*f + a*g + b*g + a*h + b*h)/ > ((c + d)*(g + h)) > > Apart[(a+b)*(e+f)*(g+h)/(c+d)+(e+f)/(g+h)] file://InputForm > Out[88]//InputForm= > ((a + b)*(e + f)*g)/(c + d) + ((a + b)*(e + f)*h)/(c + d) + > (e + f)/(g + h) > > These examples are a little hard to read without the pretty printing in > Mathematica. However, the basic problem is that Mathematica has expanded > the numerator in Together. I've also considered using Apart, but it also > can end up with more terms than are needed (partially expanded form). > Currently, I'm working with huge ratios of determinant expressions, and > expanding them out is a definite no-no. I believe the functions can > generally be written as a ratio of polynomials and I'm trying to simplify > the expressions to check things such as if a substitution forces the > equation to zero and to take derivatives and integrals. From what I can > tell, Together is the fastest code available for forming the ratio of > polynomials... does anybody know of code that does Together without > expanding the numerator? I've thought about rewriting Together as a list of > rules, but I figured my code would be too simplistic and yet too complex to > be useful. Any suggestions? I also thought that Apart might work. If it > gives me the simplest denominators, then I could multiply them all through > to form the 'together' expression. Is Apart efficient for huge expressions? > Any suggestions on how to keep Apart from partially expanding the result? > > Thanks in advance! > > Greg > > >