RE: Together, Apart, ?

*To*: mathgroup at smc.vnet.net*Subject*: [mg16981] RE: [mg16932] Together, Apart, ?*From*: "Ersek, Ted R" <ErsekTR at navair.navy.mil>*Date*: Sat, 10 Apr 1999 02:13:25 -0400*Sender*: owner-wri-mathgroup at wolfram.com

Greg Arnold wrote, ------------------------ 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)] //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 ------------------------- The function below should do what you want, but I don't know how fast it will run on a large problem. I can't see how Apart would do you much good. If your huge expression is only a means to an end you might consider a different approach. You could try Interpolation or InterpolatingPolynomial or if your function has poles you could use a ratio of IntepolatingPolynomials. In[1]:= Together2[expr_]:=expr//. ( (t1_/;Head[t1]=!=Plus)+ (t2_/;Head[t2]=!=Plus)+t3_. ):> ( Numerator[t1]*Denominator[t2]+ Numerator[t2]*Denominator[t1] )/(Denominator[t1]Denominator[t2])+t3 In[2]:= Together2[(a+b)/(c+d)+(e+f)/(g+h)] Out[2]= ((c + d)*(e + f) + (a + b)*(g + h))/ ((c + d)*(g + h)) In[3]:= Together2[(a+b)/(c+d)+(e+f)/(g+h)+(u+v)/(x+y)+z] Out[3]= ((c + d)*(g + h)*(u + v) + ((c + d)*(e + f) + (a + b)*(g + h))* (x + y) + (c + d)*(g + h)*(x + y)*z)/ ((c + d)*(g + h)*(x + y)) ----- Regards, Ted Ersek

**ListDensityPlot[ ] and DensityGraphics**

**Re: Permutations & Computer capacity**

**Together, Apart, ?**

**Re: Together, Apart, ?**