(adsbygoogle = window.adsbygoogle || []).push({}); I have the noncommutative multiply of GH[a].GHCode (Text):

Val[a_] := ToCharacterCode[ToString[a]][[1]];

GH[a].GH[b].GH[c].GH[d].GH[b] //. {GH[a_].GH[b_] :> If[Val[a] > Val[b], GH[b].GH[a], GH[a].GH[b]]}.GH[c].GH[d].GH

My goal is to order these in increasing charcter value. (Val is the function to convert to basically ascii code).

Shouldn't this work? And give GH[a].GH.GH.GH[c].GH[d] at the end?

Notice also that

Even though the rule in the 2nd one exists in the replacements of the first, it doesn't apply. I think the problem comes in the fact that its applying a rule to the position right before the last two, and once that is evaluated, does not re-evaluate it, even though no real action was taken. Though I guess if you consider it replacing itself an action, then that's what it did.Code (Text):

GH[a].GH[b].GH[c].GH[d].GH[b]

GH[a].GH[b].GH[c].GH[d].GH[b] //. {

(A_).GH[a_].GH[b_].(B_) :>

A.If[Val[a] > Val[b], GH[b].GH[a], GH[a].GH[b]].B,

(A_).GH[a_].GH[b_] :>

A.If[Val[a] > Val[b], GH[b].GH[a], GH[a].GH[b]],

GH[a_].GH[b_].(B_) :>

If[Val[a] > Val[b], GH[b].GH[a], GH[a].GH[b]].B,

GH[a_].GH[b_] :> If[Val[a] > Val[b], GH[b].GH[a], GH[a].GH[b]]}

GH[a].GH[b].GH[c].GH[d].GH[b] //. {

(A_).GH[a_].GH[b_] :> A.If[Val[a] > Val[b], GH[b].GH[a], GH[a].GH[b]]

}

Any ideas? Even if its a different method. This is something that I'm trying to write in a much more complicated way, and I need to figure out how these work.

Thanks!

**Physics Forums | Science Articles, Homework Help, Discussion**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Mathematica : Noncommutative Multiply and Replacement Rules

Tags:

Loading...

Similar Threads for Mathematica Noncommutative Multiply |
---|

Mathematica Storing Mathematica output |

Mathematica Mathematica to MATLAB |

Mathematica Cannot do the integral of the Hyper-geometric function? |

Mathematica Cannot Plot This Function in Mathematica |

Mathematica While Loop in Mathematica |

**Physics Forums | Science Articles, Homework Help, Discussion**