Re: Re: Re: Simplifying algebraic expressions

*To*: mathgroup at smc.vnet.net*Subject*: [mg67010] Re: [mg66959] Re: [mg66881] Re: [mg66839] Simplifying algebraic expressions*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>*Date*: Tue, 6 Jun 2006 06:29:52 -0400 (EDT)*References*: <200606011054.GAA20566@smc.vnet.net> <200606020809.EAA18083@smc.vnet.net> <200606050748.DAA16346@smc.vnet.net> <4484EC71.7060108@wolfram.com> <BCCD9DF4-BB59-4AFD-B8C5-4A76BFAB82C8@mimuw.edu.pl>*Sender*: owner-wri-mathgroup at wolfram.com

I suddenly remembered that I have already met a very closely related problem once before and even suggested that the transformation function f be added to Simplify. Moreover, Adams Strzebonski replied promising that he would do so: http://forums.wolfram.com/mathgroup/archive/2005/Jul/msg00717.html So it may have had something to do with the change in the development version. It also shows that my memory is no longer what it used to be :- ( (though I did feel there was something familiar about this problem). Andrzej Kozlowski On 6 Jun 2006, at 13:00, Andrzej Kozlowski wrote: > > On 6 Jun 2006, at 11:46, Carl K. Woll wrote: > >> Andrzej Kozlowski wrote: >>> Here is, I think, an optimized version of the "simplification" I >>> sent earlier: >>> rule1 = {2x -> u, 3y -> v}; rule2 = Map[Reverse, rule1]; >>> Simplify[TrigFactor[Simplify[ExpToTrig[ >>> Simplify[ExpToTrig[(-1)^(2*x + 3*y) /. rule1], >>> Mod[u, 2] == 0] /. rule2], y â?? Integers]], >>> y â?? Integers] >>> (-1)^y >>> "Optimized" means that I can't see any obvious way to make this >>> simpler. >>> Unlike other answers to the original post, this works in >>> Mathematica 5.1 and 5.2, and involves only reversible >>> operations. In other words, it constitutes a proof. On the other >>> hand, obviously, it would be ridiculous to use this approach in >>> practice: there must be a simple transformation rule (or rules) >>> missing from Simplify, which apparently has already been added >>> in the development version. >> >> Andrzej, >> >> It seems to me that your simplification approach isn't as general >> as the replacement method I advocated (a variant of which is given >> below), as rule1 and rule2 are specific to the input. Also, my >> replacement method is based on the fact that: >> >> In[30]:= Simplify[((-1)^a)^b == (-1)^(a b), Element[{a, b}, >> Integers]] >> >> Out[30]= True >> >> So, I think my approach is generally valid. > > You are right, I apologise. I did not look carefully at your code. > But now that I see some challenge ;-) I also see that I can > completley remove rule1 and rule 2 form my code and make it equally > general: > > > Simplify[TrigFactor[Simplify[ExpToTrig[ > Simplify[ExpToTrig[(-1)^PolynomialMod[2*x + 3*y, > 2]], Mod[u, 2] == 0]], y â?? Integers]], > y â?? Integers] > > > (-1)^y > > What's more, I can actually produce an even shorter code that will > produce the required simplification: > > > f[(-1)^(n_)] := (-1)^PolynomialMod[n, 2] > > > Simplify[f[(-1)^(2*x + 3*y)], TransformationFunctions -> > {Automatic, f}] > > > (-1)^y > > > Of course this ought to be modified so as to be performed only > under the assumption that x and y are integers (not very hard to > do). I suspect that this is close to what has been done in the > development version. > > Andrzej Kozlowski > > > > >> >>> Note also the following problem, which I suspect is related: >>> Simplify[(-1)^(u + v), (u | v) â?? Integers && >>> Mod[u, 2] == 0 && Mod[v, 2] == 1] >>> -1 >>> Simplify[(-1)^(u + v), (u | v) â?? Integers && >>> Mod[u, 2] == 0 && Mod[v, 2] == 0] >>> 1 >>> But >>> Simplify[(-1)^(u + v), (u | v) â?? Integers && >>> Mod[u, 2] == 0] >>> (-1)^(u + v) >>> I am sure this also gives (-1)^v in the development version. >> >> To obtain the desired simplification in 5.2, we can modify my >> previous approach as follows: >> >> power[e_, a_Plus] := Times @@ (Simplify /@ (power[e, #1]&) /@ List >> @@ a) >> power[e_, a_Integer b_?(Refine[Element[#,Integers]]&)] := (e^a)^b >> power[e_, a_] := e^a >> >> simp[expr_, assum_] := Block[{$Assumptions = assum}, >> Simplify[expr /. Power -> power] >> ] >> >> In the above I rely on the following two equivalences, verified by >> Mathematica: >> >> In[50]:= >> Simplify[e^a e^b == e^(a+b)] >> >> Out[50]= >> True >> >> In[51]:= >> Simplify[(e^a)^b == e^(a b), Element[{a,b},Integers]] >> >> Out[51]= >> True >> >> The tricky part is that Mathematica automatically converts e^a e^b >> --> e^(a+b), and as you point out above Simplify[(-1)^(u+v),...] >> doesn't work. However, Simplify[(-1)^u, ...] does work, which is >> why the Simplify appears in the definition of power[e_,a_Plus] >> before Times is applied. >> >> Here are some examples: >> >> In[56]:= >> simp[(-1)^(u+v),Mod[u,2]==0] >> >> Out[56]= >> v >> (-1) >> >> In[57]:= >> simp[(-2)^(u+v),Mod[u,2]==0] >> >> Out[57]= >> v u + v >> (-1) 2 >> >> In[58]:= >> simp[(-1)^(2x+3y),Element[{x,y},Integers]] >> >> Out[58]= >> y >> (-1) >> >> In[59]:= >> simp[(-2)^(2x+3y),Element[{x,y},Integers]] >> >> Out[59]= >> y 2 x + 3 y >> (-1) 2 >> >> Carl Woll >> Wolfram Research >> >>> Andrzej Kozlowski >>> On 2 Jun 2006, at 17:09, Andrzej Kozlowski wrote: >>>> On 1 Jun 2006, at 19:54, Amitabha Roy wrote: >>>> >>>> >>>>> Hello: >>>>> >>>>> I would like Mathematica to be able to take an expression, say, >>>>> >>>>> (-1)^{2 x + 3 y} and be able to simplify to (-1)^y. >>>>> >>>>> Is there a way one can do this ? >>>>> >>>>> Thanks >>>>> >>>> >>>> Note that you are using {} instead of (). Different kind of >>>> brackets >>>> have completely different meaning in Mathematica. >>>> I have found it amazingly hard to force Mathematica to perform this >>>> simplification. The best I could do is this. We need two rules. >>>> rule1 >>>> will replace 2x by u and 3y by v. rule 2 does the opposite: it >>>> replaces u by 2x and v by 2y. >>>> >>>> rule1 = {2x -> u, 3y -> v};rule2 = Map[Reverse, rule1]; >>>> >>>> Now: >>>> >>>> >>>> Simplify[TrigFactor[ >>>> FullSimplify[ExpToTrig[ >>>> FullSimplify[ >>>> ComplexExpand[ >>>> (-1)^(2*x + 3*y) /. >>>> rule1], Mod[u, 2] == >>>> 0] /. rule2], >>>> y â?? Integers]], >>>> y â?? Integers] >>>> >>>> >>>> (-1)^y >>>> >>>> Uff... Surely, this ought to be easier... >>>> >>>> Andrzej Kozlowski >>>> Tokyo, Japan >>>> >> >

**References**:**Simplifying algebraic expressions***From:*Amitabha Roy <aroy@cs.bc.edu>

**Re: Simplifying algebraic expressions***From:*Andrzej Kozlowski <akoz@mimuw.edu.pl>

**Re: Re: Simplifying algebraic expressions***From:*Andrzej Kozlowski <akoz@mimuw.edu.pl>

**Re: New Analytical Functions - Mathematica Verified**

**Re: Re: Re: Simplifying algebraic expressions**

**Re: Re: Re: Simplifying algebraic expressions**

**Re: Re: Re: Simplifying algebraic expressions**