Commutator

From NARS2000
Revision as of 14:31, 7 February 2024 by WikiSysop (talk | contribs) (Created page with "<table border="1" cellpadding="5" cellspacing="0" rules="none" summary=""> <tr> <td> <table border="0" cellpadding="5" cellspacing="0" summary=""> <tr> <td valign="top"><apll>Z←{L} <i>f</i>⍫<i>g</i> R</apll></td> <td></td> <td></td> <td>applies the function <apll><i>g</i></apll> then <apll><i>f</i></apll> then <apll><i>g</i>⍣¯1</apll> and then <apll><i>f</i>⍣¯1</apll> to or between the arguments.</td> </tr> </table> <...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
Z←{L} fg R applies the function g then f then g⍣¯1 and then f⍣¯1 to or between the arguments.
L is an optional array.
R is an array.
f is an arbitrary ambivalent function with an inverse.
g is an arbitrary monadic function with an inverse.

Introduction

The concept of the Commutator operator is taken from mathematical Group Theory from the 1830s.

For example, the algorithm for Partitioned Plus Scan where P is the Boolean partition vector (always with a leading 1), in modern notation looks like this:

      P←1 0 0 1 0 1 0 0 0
      R←1 2 3 4 5 6 7 8 9 
      +\R-P\¯2-\P/+\¯1↓0,R
1 3 6 4 9 6 13 21 30

An interesting observation on this one-liner is that it contains two interleaved pairs of inverses: P\ and P/ as one and ¯2-\ and +\ as the other. This interleaving of inverses exactly matches the template for the Commutator Operator:

f-1 g-1 f g

where g ←→ +\ g⍣¯1 ←→ ¯2∘(-\) f ←→ P∘/ f⍣¯1 ←→ P∘\

which can be re-written as

+\R-P∘/⍫(+\)¯1↓0,R

Implementation

This operator is implemented via the anonymous function:

{⍺←⍣0 ⋄ (⍵⍵ ⍺) ⍺⍺⍣¯1 ⍵⍵⍣¯1 (⍵⍵ ⍺) ⍺⍺ ⍵⍵ ⍵}