MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: TransformationFunctions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102120] Re: TransformationFunctions
  • From: O <kakabomba at gmail.com>
  • Date: Thu, 30 Jul 2009 05:30:35 -0400 (EDT)
  • References: <h46p31$e4g$1@smc.vnet.net> <200907230754.DAA26659@smc.vnet.net>

On Jul 24, 3:14 am, Andrzej Kozlowski <a... at mimuw.edu.pl> wrote:
> On 24 Jul 2009, at 15:46, Oles Zaburannyi wrote:
>
>
>
>
>
> > 2009/7/23 Andrzej Kozlowski <a... at mimuw.edu.pl>
>
> > On 23 Jul 2009, at 16:54, Peter Breitfeld wrote:
>
> > ".... at ntaxa.com" wrote:
>
> > Can anyone advice why following code does not work:
>
> > In[538]:=tf[z_NonCommutativeMultiply] := -z[[2]]**z[[1]]
> > In[539]:=Simplify[x ** y + y ** x,TransformationFunctions -> {tf,
> > Automatic}]
> > Out[539]:=x ** y + y ** x
>
> > I expect rather 0
>
> > By the way:
> > In[540]:=x ** y + tf[y ** x]
> > Out[540]:=0
>
> > I think, the problem here is, that Simplify will apply tf to both
> > products. So I would suggest you do something like this:
>
> > tfrule = (x_ ** y_ + y_ ** x_) :> 0;
> > tf[expr_] := expr /. tfrule;
> > Simplify[x ** y + y ** x, TransformationFunctions -> {tf}]
>
> > Out=0
>
> > -- _________________________________________________________________
> > Peter Breitfeld, Bad Saulgau, Germany --http://www.pBreitfeld.de
>
> > There are problems with this approach.
> > Consider:
>
> > tfrule = (x_ ** y_ + y_ ** x_) :> 0;
> > tf[expr_] := expr /. tfrule;
>
> > Simplify[x ** y + y ** x, TransformationFunctions -> {tf}]
> > 0
>
> > but
>
> > Simplify[2 x ** y + y ** x, TransformationFunctions -> {tf}]
> > 2 x ** y + y ** x
>
> > by contrast:
>
> > tf1[expr_] :=
> > expr /. z_NonCommutativeMultiply :> If[Not[OrderedQ[z]], -Sort[z], z]
>
> > In[42]:= Simplify[x ** y + y ** x, TransformationFunctions ->  
> > {Automatic, tf1}]
> > Out[42]= 0
>
> > but also
>
> > Simplify[2 x ** y + y ** x, TransformationFunctions -> {Automatic,  
> > tf1}]
> > x ** y
>
> > Andrzej Kozlowski
>
> > thanks, but your solution give incorrect result for
>
> > In[3]:=Simplify[(z ** x ** y + z ** y ** x),  
> > TransformationFunctions -> {Automatic, tf1}]
> > Out[3]:=-2 x ** y ** z
> > (should be 0)
>
> > As i understand my main problem is that Simplify apply  
> > transformation function and select simplest form AT EACH STEP.
> > So, if globally simplest form is achieved only by MORE COMPLEX  
> > intermediate forms that simplification will be omited.
>
> > Am i right?
>
> > in another words simplification like
>
> > initial form -> a bit complex form -> maybe even more complex form -
> > > simplest form
>
> > is omited by Simplify?
>
> > --
> > No Signature
>
> You are right. I did not give this enough thought and did not consider =
 
> the possibility of multiplying more than two
> elements. However, this is easy to fix:
>
> tf1[expr_] :=
>   expr /. z_NonCommutativeMultiply :>
>     If[Not[OrderedQ[z]], Signature[List @@ z]*Sort[z], z]
>
> I think will not work correctly:
>
> Simplify[x ** y + y ** x, TransformationFunctions -> {Automatic, tf1}]
> 0
>
> Simplify[(z ** x ** y + z ** y ** x),
>   TransformationFunctions -> {Automatic, tf1}]
>   0
>
> As for your question; yes. Simplification generally only proceeds to  
> forms which are simpler (with respect to the given complexity  
> function, which can be user controlled) at every step. However, there  
> are some exceptions to this, because at eeach step simplify remembers  
> not only the form of the expression that has the least complexity  
> found so far but also (for most expression) a standard form of the  
> expression. It will therefore sometimes notice cancellations when  
> between two expressions which have the same standard form, even if  
> there is no complexity decreasing route "connecting" them. But this is =
 
> not really something that a user can control and shows itself most  
> often when Simplify is used to show that some expression is 0 (rather  
> then in finding the simplest form of the expression).
>
> Andrzej Kozlowski

ok, thanks for answer.

can you tell me neither my plan is realistic or not?

for example i have some expression:

a1**a2**a3**a4**a5 and have some transformation function ai**aj ->
aj**ai + fij

what i want from simplify:
1. i expect that simplify will try to to apply my function to EACH
possible product (namely a1 and a2, a2 and a3, a3 and a4, a4 and a5).
2. i expect that even after applying transformation function
expression will be more complicated simplify will try to transform it
further.

As i can understand answer for second question is NO
What about first question.

I think my plan is rather common and a lot of people waste time to do
something like that, can you advise me only to dig in that direction
or not?

thanks


  • Prev by Date: Re: The audience for Mathematica
  • Next by Date: Re: Re: The audience for Mathematica (Was: Show doesn't
  • Previous by thread: Re: Re: TransformationFunctions
  • Next by thread: Re: Re: TransformationFunctions