Skip to main content
Commonmark migration
Source Link

###Brief explanation###

Brief explanation

###Brief explanation###

Brief explanation

added 2 characters in body
Source Link
march
  • 24.9k
  • 2
  • 48
  • 108
rel = {ncm[c___, a, a, d___] :> ncm[c, i, d] , ncm[c___, b, b, b, d___] :> ncm[c,i, d] , ncm[c___, b, b, a, d___] :> ncm[c, a, b, d] , ncm[c___, b, a, d___] :> ncm[c, a, b, b, d] , ncm[a__, i] :> ncm[a] , ncm[i, a__] :> ncm[a] , ncm[a_] :> a } 
rel = {ncm[c___, a, a, d___] :> ncm[c, i, d] , ncm[c___, b, b, b, d___] :> ncm[c, d] , ncm[c___, b, b, a, d___] :> ncm[c, a, b, d] , ncm[c___, b, a, d___] :> ncm[c, a, b, b, d] , ncm[a__, i] :> ncm[a] , ncm[i, a__] :> ncm[a] , ncm[a_] :> a } 
rel = {ncm[c___, a, a, d___] :> ncm[c, i, d] , ncm[c___, b, b, b, d___] :> ncm[c,i, d] , ncm[c___, b, b, a, d___] :> ncm[c, a, b, d] , ncm[c___, b, a, d___] :> ncm[c, a, b, b, d] , ncm[a__, i] :> ncm[a] , ncm[i, a__] :> ncm[a] , ncm[a_] :> a } 
Fixed code, added explanation.
Source Link
march
  • 24.9k
  • 2
  • 48
  • 108
rel = {ncm[c___, a, a, d___] :> ncm[c, i, d] , ncm[c___, b, b, b, d___] :> ncm[c, d] , ncm[cncm[c___, b, b, a, d]d___] :> ncm[c___ncm[c, a, b, d___]d] , ncm[c___, b, a, d___] :> ncm[c, a, b, b, d] , ncm[a__, i] :> ncm[a] , ncm[i, a__] :> ncm[a] , ncm[a_] :> a } 

###Brief explanation###

To answer your questions:

  • NonCommutativeMultiply has very little rules associated with it. In particular, ncm[a] doesn't evaluate, i.e. it just evaluates to ncm[a]. So we have to add the rule that if we have ncm[i], for instance, this will evaluate to i.

  • _ is Blank. It is a pattern that will match any single expression. __ is BlankSequence. It is a pattern will match any sequence of one or more expressions. ___ is BlankNullSequence. It will match any sequence of expressions, including the Null Sequence. Meditate on the results of these three evaluations:

    {f[], f[a], f[a, b]} /. f[_] :> f[1]

    {f[], f[a], f[a, b]} /. f[__] :> f[1]

    {f[], f[a], f[a, b]} /. f[___] :> f[1]

rel = {ncm[c___, a, a, d___] :> ncm[c, i, d] , ncm[c___, b, b, b, d___] :> ncm[c, d] , ncm[c, b, b, a, d] :> ncm[c___, a, b, d___] , ncm[c___, b, a, d___] :> ncm[c, a, b, b, d] , ncm[a__, i] :> ncm[a] , ncm[i, a__] :> ncm[a] , ncm[a_] :> a } 
rel = {ncm[c___, a, a, d___] :> ncm[c, i, d] , ncm[c___, b, b, b, d___] :> ncm[c, d] , ncm[c___, b, b, a, d___] :> ncm[c, a, b, d] , ncm[c___, b, a, d___] :> ncm[c, a, b, b, d] , ncm[a__, i] :> ncm[a] , ncm[i, a__] :> ncm[a] , ncm[a_] :> a } 

###Brief explanation###

To answer your questions:

  • NonCommutativeMultiply has very little rules associated with it. In particular, ncm[a] doesn't evaluate, i.e. it just evaluates to ncm[a]. So we have to add the rule that if we have ncm[i], for instance, this will evaluate to i.

  • _ is Blank. It is a pattern that will match any single expression. __ is BlankSequence. It is a pattern will match any sequence of one or more expressions. ___ is BlankNullSequence. It will match any sequence of expressions, including the Null Sequence. Meditate on the results of these three evaluations:

    {f[], f[a], f[a, b]} /. f[_] :> f[1]

    {f[], f[a], f[a, b]} /. f[__] :> f[1]

    {f[], f[a], f[a, b]} /. f[___] :> f[1]

Source Link
march
  • 24.9k
  • 2
  • 48
  • 108
Loading