
Re: Another question about Factor
Posted:
Nov 23, 2012 7:29 AM


Am 23.11.2012 05:28, schrieb Tang Laoya: > On Friday, November 23, 2012 9:35:01 AM UTC+8, Nasser M. Abbasi wrote: >> On 11/22/2012 7:10 PM, Tang Laoya wrote: >> >> >> >>> >> >>> k11 = 1/60 (b1^2 + c1^2 + d1^2) >> >>> k11 = HornerForm[k11] >> >>> >> >>> The outputs are: >> >>> 1/60 (b1^2 + c1^2 + d1^2) >> >>> b1^2/60 + c1^2/60 + d1^2/60 >> >>> >> >>> respectively. >> >>> >> >>> How to do to let the numbers are also been combined? >> >>> >> >> >> >> >> >> In[25]:= Simplify[k11] >> >> Out[25]= 1/60 (b1^2+c1^2+d1^2) > > Dear Nasser, > > Thank you very much for your kindly reply. What I mean is that 'Simplify' conflicts with 'HornerForm'. I wish both variables and numbers be combined, which could lead to smallest number of floating operations. > > Thanks, > Tang Laoya >
Hi!
I do not see a (very) simple approach, but the following seems to work:
In[1]:= vv = Det[{{1, 1, 1, 1}, {x1, x2, x3, x4}, {y1, y2, y3, y4}, {z1, z2, z3, z4}}];
In[2]:= hf = HornerForm[vv/60, Sort[Variables[vv]]]
Out[2]= x4*(y3*(z1/60  z2/60) + y1*(z2/60  z3/60) + y2*((z1/60) + z3/60)) + x2*(y4*(z1/60  z3/60) + y1*(z3/60  z4/60) + y3*((z1/60) + z4/60)) + x3*(y4*((z1/60) + z2/60) + y2*(z1/60  z4/60) + y1*((z2/60) + z4/60)) + x1*(y4*((z2/60) + z3/60) + y3*(z2/60  z4/60) + y2*((z3/60) + z4/60))
In[3]:= hf //. (a_.)*(x_) + (b_.)*(y_) /; Abs[a] == Abs[b] && a^2 != 1 :> Block[{aa = Abs[a]}, aa*((a*x)/aa + (b*y)/aa)]
Out[3]= (1/60)*(x4*(y3*(z1  z2) + y1*(z2  z3) + y2*(z1 + z3)) + x2*(y4*(z1  z3) + y1*(z3  z4) + y3*(z1 + z4)) + x3*(y4*(z1 + z2) + y2*(z1  z4) + y1*(z2 + z4)) + x1*(y4*(z2 + z3) + y3*(z2  z4) + y2*(z3 + z4)))
HTH, Peter

