Re: Re: How to get an optimal simplification?

*To*: mathgroup at smc.vnet.net*Subject*: [mg89489] Re: [mg89465] Re: How to get an optimal simplification?*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>*Date*: Tue, 10 Jun 2008 07:15:10 -0400 (EDT)*References*: <g2iir2$rj5$1@smc.vnet.net> <g2j078$528$1@smc.vnet.net> <200806100741.DAA09323@smc.vnet.net>

On 10 Jun 2008, at 16:41, yaqi wrote: > On Jun 9, 5:21 am, Jean-Marc Gulliet <jeanmarc.gull... at gmail.com> > wrote: >> yaqi wrote: >>> I expected to get: >>> {t1,t2,t3} >> >>> with the expression: >>> Simplify[{a - b, b - c, c - a}, {t1 == a - b, t2 == b - c, t= > 3 == c - >>> a}] >> >>> But I only get {-t2-t3,t2,t3}, which is a little bit annoying. >> >>> I know I can do the simplifications separately like, >>> Simplify[Simplify[Simplify[{a - b, b - c, c - a}, t1 == a - b], = > t2 >>> == b - c], t3 == c - a] >> >>> But I still like to get the optimal result with one simplify >>> operation. >> >>> Is there an answer? (the answer is useful for one of my big >>> derivations.) >> >> I am not sure if the following will apply straightforwardly to your >> bigger expressions, but you could use a list of rules with the >> *ReplaceRepeated[]* operator (short cut //. double-forward slash and >> period, though in your example *ReplaceAll[]* is enough) or compute a >> *GroebnerBasis[]* for the variables t1, t2, t3, and eliminating a, b, >> and c. For instance, >> >> In[1]:= {a - b, b - c, c - a} //. {a - b -> t1, b - c -> t2, >> c - a -> t3} >> >> Out[1]= {t1, t2, t3} >> >> In[2]:= GroebnerBasis[{a - b, b - c, c - a, t1 - a + b, t2 - b + c, >> t3 - c + a}, {t1, t2, t3}, {a, b, c}] >> >> Out[2]= {t3, t2, t1} >> >> Regards, >> -- Jean-Marc- Hide quoted text - >> >> - Show quoted text - > > 'Replace' is not the way I want, because it can only replace the terms > that exactly match the expression. For example, > > { b - a, b - c, c - a} /. {a - b -> t1, b - c -> t2, > c - a -> t3} > > does not work. > > I am guessing that 'Simplify' is trying to simplify the equation with > conditions one-by-one but not simutaneously. Not really. It is all to do with variable ordering in the function PolynomialReduce, which is used by Simplify. Note the follwing: Last[PolynomialReduce[a - b, {t1 - a + b, t2 - b + c, t3 - c + a}, {a, b, c}]] t1 Last[PolynomialReduce[b - c, {t1 - a + b, t2 - b + c, t3 - c + a}, {a, b, c}]] t2 but Last[PolynomialReduce[c - a, {t1 - a + b, t2 - b + c, t3 - c + a}, {a, b, c}]] -t1 - t2 However, if you simply change the order of varibles you will get: Last[PolynomialReduce[c - a, {t1 - a + b, t2 - b + c, t3 - c + a}, {b, a, c}]] t3 but, unfortunately, with this order you get: Last[PolynomialReduce[b - c, {t1 - a + b, t2 - b + c, t3 - c + a}, {b, a, c}]] -t1 - t3 So the only way Simplify could return the answer you want would be to apply PolynomialReduce with every possible ordering of variables to every term in your expression and then choose the expression with the lowest complexity. But this sort of procedure would be obviously unrealistic in terms of time required to complete it for any but the simplest expressions. > > > Acturally what I am doing is to integrate a function on an arbitrary > triangle with coordinates of three vertices, I am expecting to get a > formula with something like triangle area, surface-volume ratio, etc. > The function could be very complicated. > It sounds like the thing to do is to first obtain the formula and then eliminate the variables you do not want by means of GroebnerBasis as suggested by Jean-Marc. Andrzej Kozlowski

**References**:**Re: How to get an optimal simplification?***From:*yaqi <yaqiwang@gmail.com>