HoriAsso - Documentation: Difference between revisions

From Drorbn
Jump to navigationJump to search
No edit summary
No edit summary
Line 1: Line 1:
[[Installation and Setup for using Java in Mathematica]]
[[Installation and Setup for using Java in Mathematica]]
=How to set up a system for using Java in Mathematica=
In this project, we will be mainly using Commands in Mathematica to access Java programs that we write. Here is how to set up the system:


[[Java Class Documentation]]


==How to install ''Mathematica'','' J/Link'', and ''Java''==
*Install ''Mathematica'' following the [http://documents.wolfram.com/mathematica/GettingStarted/SettingUp/InstallingMathematica.html official instructions].


*''Jlink'' is already completely installed in ''Mathematica 4.2'' and later. If you are using earlier versions of ''Mathematica'', you can install ''JLink'' following the [http://www.wolfram.com/solutions/mathlink/jlink/Installation.html official instructions].


*Download ''JRE 5.0 Update 6'' (latest as of June 2006) the latest version from [http://java.sun.com/j2se/1.5.0/download.js Sun] and install it following the official [http://java.sun.com/j2se/1.5.0/install.html official instructions].


==How to start using ''Jlink'' in a ''Mathematica'' notebook==
*Write the Java source code (''.java'' files) and compile it using the command
javac file.java
Place the compiled files (''.class'' files) in the directory you want. (I have not tried to make .jar files yet so I will not write about it here)


===Installation===
*For detailed documentation on ''JLink'', please consult the ''Jlink'' manual in the ''Mathematica'' Help Browser. The following are extracted from there.


Download the FreeLieAlgebra folder from the repository. It should include all necessary compiled Java Class files, and the Mathematica/Java interface "HoriAssoInterface.m"; otherwise, if you could be connected to the repository during the Mathematica session, follow the instructions (in the Necessary Initialization Steps section) and enter the path to the repository accordingly.
*Open a ''Mathematica'' notebook, install ''JLink'' by (writing and executing):
Needs["JLink`"]


(I will zip the Source file in the future)
*Install ''Java'' by:
InstallJava[]
or to use a specific java runtime if you have more than one installed on your computer:
InstallJava[commandLine->"/wherever/java/is"] in Linux
InstallJava[CommandLine -> "d:\\\\path\\to\\javaw.exe"] in Windows


*Add the directory which contains the compiled java (.class) files to the class path, ie, where Java will look for class files, by
AddToClassPath["wherever/my/class/files/are"] in Linux
AddToClassPath["c:\\my\\java\\dir"] in Windows


*Create New Java Objects by
JavaNew["classname1",constructorArg1,constructorArg2...]


===Demo Mathematica NoteBook===


A Mathematica notebook, HoriAssoFLnSpaceDemo.nb, to demonstrate what follows can be acquired in the repository. Simply do the installation steps above, download and open the notebook, and evaluate the cells as you like.
*Access the non-static methods and variables of any object the same way you would in Java except replace "'''.'''" (''java'') by "'''@'''" (''Mathematica'') and "'''()'''" (''Java'') by "'''[]'''" (''Mathematica''). Access static methods or variables by replacing "'''.'''" in ''Java'' by "'''`'''" in ''Mathematica''. (I haven't used the static methods yet so I am not entirely sure.)

===Usage===

The HoriAsso Mathematica interface is set up to do computations only in Free Lie algebra with 1,2, and 3 generators, named FL2, FL3, FL4 respectively (the suffix is the number of generators +1). You could do computations in Free Lie Algebras with more generators if you used the Java classes directly.


====Necessary Initialization Steps====

1.In a Mathematica session, load the Java/Mathematica interface by:

{{In|n=1|in=<nowiki> <<"/path_to_interface_folder/HoriAssoInterface.m" </nowiki>}}
where "path_to_interface_folder" is the folder containing the downloaded HoriAssoInterface.m file or simply the "Source" folder of this project's repository.


2(Optional). For faster and bigger calculations, reinstall the Java runtime with the option to use as much memory as designated:
{{In|n=1|in=<nowiki> ReinstallJava[CommandLine -> "path_to_Java -Xmx800M" </nowiki>}}
where 800M in the last argument can be replaced by your choice of maximum memory to use according to your computer specs.

3. Let Mathematica know where to look for the necessary Java class files:

{{In|n=1|in=<nowiki> SetHoriAssoPath["/path_to_Java_Class_folder"]; </nowiki>}}
where "path_to_Java_Class_folder" contains the downloaded Java Class files, or simply the path to the "Source" folder in our repository.

4. Create the Lyndon bases for all three Free Lie Algebras with 1, 2, and 3 generators respectively by:

{{In|n=1|in=<nowiki> InitializeHoriAssoSpace[12]; </nowiki>}}

or Create the Lyndon basis separately for the different Free Lie Algebras by:

{{In|n=1|in=<nowiki> CreateFL2Basis[any_number]; </nowiki>}}
{{In|n=1|in=<nowiki> CreateFL3Basis[any_num_<=_20]; </nowiki>}}
{{In|n=1|in=<nowiki> CreateFL4Basis[any_num_<=_14_(12_is_safe)]; </nowiki>}}

where the argument controls up to what word length the Lyndon bases will contain elements of. Please read the "Algebraic operations" section below for its effect.

Performance Note: For the default java runtime on a computer with 1G RAM, 12 as the maximum word length in "InitializeHoriAssoSpace" or "CreateFL4Basis" seems to be quite safe. You can choose up to 14 if you have chosen to run Java with 800M memory in Step 2.


To check the dimension of the Free Lie Algebras at a given length (less than the maximum word length used in creating the basis):

{{InOut|n=3|in = <nowiki>GetFLnDimension[4,14]</nowiki>|out=341484}}
where the first argument is n in FLn, i.e., the number of generators + 1, and the second is the wordlength at which the basis dimension is returned.


====Notation====

Any Free Lie Algebra element is a linear combination of Lie-trees, which are nested Lie Brackets of the generators, e.g. [a,[[a,b],[a,c]]] where the square brackets are the Lie Brackets.

In the HoriAsso setup:
1. Letters starting with lower case "a" are used as generators, i.e., a Lie tree in Free Lie Algebra with 3 generators (FL4) will/should contain only a's, b's, and/or c's.

2. Only two tree structures are used and allowed, the right Comb, and the Lyndon Word.

Right-Combs represent the tree structure [a,[a,[a,[a,[a,[a,[a,[a...[a,b]]]]]]]]]... is represented in our setup, for example, as
{{In|n=2|in=<nowiki>RCombExample=RComb[a,a,a,a,a,a,a,a,...a,b] </nowiki>}}

Lyndon Words are words that are smaller by alphabetical order than any of its right subwords. Since they are Hall Words, and each word implies a unique tree structure. They are represented, for example, as

{{In|n=2|in=<nowiki>LyndonWordExample=LW[a,a,b,a,b,a,b,a,b] </nowiki>}}

You can check to see if a word satisfies the definition of a Lyndon Word:

{{InOut|n=3|in = <nowiki>IsLyndon[LW[a,b,a]</nowiki>|out=False}}

Note: In Java, you could replace the left or right subtree of a Lie tree by any tree, giving structures that are neither Right-Combs or Lyndon. However, the interface assumes that if it is not a Lyndon Word, it would be a Right Comb; using those Java methods (namely javatree@setLeft(or right)Subtree(new_left(or_right)_subtree)) directly in Mathematica will cause errors in calculations.


3, Free Lie Algebra elements are represented as a linear combination of Lyndon Words (LW) and Right-Combs (RComb) with an enveloping head FLn, where n is the number of generators + 1, e.g.:

{{In|n=2|in=<nowiki>LieAlgebraElementExample=FL3[LW[a,a,b,a,b,a,b,a,b]+3RComb[a,b,a]] </nowiki>
>|out=FL3[LW[a,a,b,a,b,a,b,a,b]+3RComb[a,b,a]}}



====Algebraic Operation====


1. Scalar multiplication and Addition

You could form either linear combinations of words (RComb and LW) as you would with other Mathematica expressions, or form the linear combinations and give them context by putting them under the head of FL2, FL3, FL4. The difference is that in the first case, the sum is simply formal and is the original Mathematica plus, times function, whereas in the case with the FL2(or 3 or 4) heads do the sum in the Lyndon basis.

At the moment the coefficients for the FLn elements need to be Integers. This will be replaced with rational numbers soon.

Sum of Linear combination of WordS:
{{InOut|n=3|in = <nowiki>
LinCombOfWords = 2 RComb[a, b, a, b] + LW[a, b, b, a, b, b, b] - 4LW[a, b, a, b, a, b, b] - RComb[a, b, a, b] + LW[a, b, b, a, b, b, b]</nowiki>|out=-4 LW[a, b, a, b, a, b, b] + 2 LW[a, b, b, a, b, b, b] + RComb[a, b, a, b]}}


Sum of Free Lie Algebra elements (a linear combination of words wraps around
{{InOut|n=3|in = <nowiki> SumOfFL3Elements = FL3[ -4 LW[a, b, a, b,
a, b, b]] + FL3[2LW[a, b, b, a, b, b, b]+RComb[a, b, a, b]]</nowiki>|out=FL3[-LW[a, a, b, b] - 4 LW[a, b, a, b, a, b, b] + 2 LW[a, b, b, a, b, b, b]]}}


Note that the FLn elements itself is not automatically reduce to the Lyndon basis form, but a sum of the FLn elements is.


2. Reduce to linear combination of Lyndon basis elements

You could reduce a single word (RComb and LW) or a Free Lie Algebra elements into a linear combination of Lyndon basis elements.

For reducing a word to Lyndon form, the word length is only limited by performance. For a good size example:
{{InOut|n=3|in = <nowiki>
ReduceToLyndon[RComb[a, b, b, a, a, b, a, b, a, b, b, a, b]]</nowiki>|
out=LW[a, a, a, a, a, a, b, b, b, b, b, b, b] + 4 LW[a, a, a, a, a, b, a, b, b, b,
b, b, b] + 6 LW[a, a, a, a, a, b, b, a, b, b, b, b, b] + 3 LW[a, a, a, a,
a, b, b, b, a, b, b, b, b] - LW[a, a, a, a, a, b, b, b, b, a, b, b,
b] - 5 LW[a, a, a, a, a, b, b, b, b, b, a, b, b] -
7 LW[a, a, a, a, a, b, b, b, b, b, b, a, b] - 4 LW[a, a, a, a, b, a, a, b,
b, b, b, b, b] +
9 LW[a, a, a, a, b, a, b, a, b, b, b, b, b] + 9 LW[a, a, a, a, b, a, b, b,
a, b, b, b,
b] - LW[a, a, a, a, b, a, b, b, b, a, b, b, b] - 10 LW[a, a, a, a, b, a, b,
b, b, b, a, b, b] - 12 LW[a, a, a, a, b, a, b, b, b, b, b, a, b] - 2
LW[a, a, a, a, b, b, a, a, b, b, b, b,
b] - 4 LW[a, a, a, a, b, b, a, b, a, b, b, b, b] + 3 LW[a, a, a, a, b, b,
a, b, b, a, b, b,
b] - 2 LW[a, a, a, a, b, b, a, b, b, b, a, b, b] - 12 LW[a, a, a, a, b, b,
a, b, b, b, b, a,
b] + 2 LW[a, a, a, a, b, b, b, b, a, b, a, b, b] + 6 LW[a, a, a, a, b, b, b,
b, a, b, b, a, b] + LW[a, a, a, a, b, b, b, b, b, a, a, b, b] + 10 LW[
a, a, a, a,
b, b, b, b, b, a, b, a, b] + 2 LW[a, a, a, a, b, b, b, b, b, b, a, a, b] -
6 LW[a, a, a, b, a, a, b, a,
b, b, b, b, b] - 6 LW[a, a, a, b, a, a, b, b, a, b, b, b, b] + 2 LW[a, a,
a, b, a, a, b, b,
b, b, a, b, b] + 8 LW[a, a, a, b, a, a, b, b, b, b, b, a, b] + 2 LW[a, a,
a, b, a, b, a, a,
b, b, b, b, b] + 8 LW[a, a, a, b, a, b, a, b, a, b, b, b, b] + 4 LW[a, a,
a, b, a, b, a, b,
b, a, b, b, b] - 4 LW[a, a, a, b, a, b, a, b, b, b, a, b, b] - 8 LW[a, a,
a, b, a, b, a, b,
b, b, b, a, b] - 2 LW[a, a, a, b, a, b, b, a, b, a, b, b, b] - 4 LW[a, a,
a, b, a, b, b, a,
b, b, b, a, b] + 2 LW[a, a, a, b, a, b, b, b, a, b, b, a, b] + 2 LW[a, a,
a, b, a, b, b, b,
b, a, a, b, b] + 4 LW[a, a, a, b, a, b, b, b, b, a, b, a, b] - LW[a, a, a,
b, b, a, a, b, b,
a, b, b, b] + LW[a, a, a, b, b, a, a, b, b, b, b, a, b] - LW[a, a, a, b, b,
a, b, a, b, a,
b, b, b] + 2 LW[a, a, a, b, b, a, b, b, b, a, b, a, b] - 2 LW[a, a, a, b,
b, b, b, a, b, a, b, a, b] + 2 LW[a, a, b, a, b, a, b, a, b, a, b, b, b]}}

For reducing an FLn element to Lyndon form, the word length has to be smaller than the maximum word length specified in "iniatializeHoriAssoSpace(maxWordLength)":

{{InOut|n=4| in=<nowiki>ReduceToLyndon[FL3[LW[a, a, b, a, b] + 4RComb[a, b, a, b, a, b, a]]] </nowiki>|
out=FL3[LW[a, a, b, a, b] - 4 LW[a, a, a, a, b, b,
b] - 4 LW[a, a, a, b, a, b, b] + 4 LW[a, a, a, b, b, a, b]]</nowiki>}}


Note: the two notations will probably merge.

4, Lie Brackets

Finally, you could compute the Lie bracket of two individual words (RComb and/or LW) or two Free Lie Algebra elements (FL2,3,4 elements), the results of which are reduced into the Linear combinations of lyndon words already:


{{InOut|n=4| in=<nowiki>Bracket[RComb[a, b, b, a], RComb[b, a, a, b, a]] </nowiki>|
out=-LW[a, a, a, b, b, a, a, b, b] + LW[a, a, b, a, b, a, a, b, b]</nowiki>}}


{{InOut|n=4| in=<nowiki> Bracket[FL4[LW[a, b, c, a, c] + 2RComb[a, b, c, b]], FL4[-2RComb[a, b, b, c, a, b] + 4RComb[b, a, c]]]</nowiki>|
out=FL4[8 LW[a, b, b, c, a, c, b] - 4 LW[a, b, c, a, c, a, c, b] -
4 LW[a, b, c, a, c, b, a, c] + 4 LW[a, a, b, c, b, b, a, b, b,
c] + 4 LW[a, a, c, b, b, b, a, b, b, c] - 2 LW[a, a, b, c, b,
b, a, b, c, a, c] - 2 LW[a, a, c, b, b, b, a, b, c, a, c]]
</nowiki>}}

Revision as of 17:35, 15 August 2006

Installation and Setup for using Java in Mathematica

Java Class Documentation



Installation

Download the FreeLieAlgebra folder from the repository. It should include all necessary compiled Java Class files, and the Mathematica/Java interface "HoriAssoInterface.m"; otherwise, if you could be connected to the repository during the Mathematica session, follow the instructions (in the Necessary Initialization Steps section) and enter the path to the repository accordingly.

(I will zip the Source file in the future)


Demo Mathematica NoteBook

A Mathematica notebook, HoriAssoFLnSpaceDemo.nb, to demonstrate what follows can be acquired in the repository. Simply do the installation steps above, download and open the notebook, and evaluate the cells as you like.

Usage

The HoriAsso Mathematica interface is set up to do computations only in Free Lie algebra with 1,2, and 3 generators, named FL2, FL3, FL4 respectively (the suffix is the number of generators +1). You could do computations in Free Lie Algebras with more generators if you used the Java classes directly.


Necessary Initialization Steps

1.In a Mathematica session, load the Java/Mathematica interface by:

In[1]:= <<"/path_to_interface_folder/HoriAssoInterface.m"

where "path_to_interface_folder" is the folder containing the downloaded HoriAssoInterface.m file or simply the "Source" folder of this project's repository.


2(Optional). For faster and bigger calculations, reinstall the Java runtime with the option to use as much memory as designated:

In[1]:= ReinstallJava[CommandLine -> "path_to_Java -Xmx800M"

where 800M in the last argument can be replaced by your choice of maximum memory to use according to your computer specs.

3. Let Mathematica know where to look for the necessary Java class files:

In[1]:= SetHoriAssoPath["/path_to_Java_Class_folder"];

where "path_to_Java_Class_folder" contains the downloaded Java Class files, or simply the path to the "Source" folder in our repository.

4. Create the Lyndon bases for all three Free Lie Algebras with 1, 2, and 3 generators respectively by:

In[1]:= InitializeHoriAssoSpace[12];

or Create the Lyndon basis separately for the different Free Lie Algebras by:

In[1]:= CreateFL2Basis[any_number];
In[1]:= CreateFL3Basis[any_num_<=_20];
In[1]:= CreateFL4Basis[any_num_<=_14_(12_is_safe)];

where the argument controls up to what word length the Lyndon bases will contain elements of. Please read the "Algebraic operations" section below for its effect.


Performance Note: For the default java runtime on a computer with 1G RAM, 12 as the maximum word length in "InitializeHoriAssoSpace" or "CreateFL4Basis" seems to be quite safe. You can choose up to 14 if you have chosen to run Java with 800M memory in Step 2.


To check the dimension of the Free Lie Algebras at a given length (less than the maximum word length used in creating the basis):

In[3]:= GetFLnDimension[4,14]
Out[3]= 341484

where the first argument is n in FLn, i.e., the number of generators + 1, and the second is the wordlength at which the basis dimension is returned.


Notation

Any Free Lie Algebra element is a linear combination of Lie-trees, which are nested Lie Brackets of the generators, e.g. [a,[[a,b],[a,c]]] where the square brackets are the Lie Brackets.

In the HoriAsso setup: 1. Letters starting with lower case "a" are used as generators, i.e., a Lie tree in Free Lie Algebra with 3 generators (FL4) will/should contain only a's, b's, and/or c's.

2. Only two tree structures are used and allowed, the right Comb, and the Lyndon Word.

Right-Combs represent the tree structure [a,[a,[a,[a,[a,[a,[a,[a...[a,b]]]]]]]]]... is represented in our setup, for example, as

In[2]:= RCombExample=RComb[a,a,a,a,a,a,a,a,...a,b]

Lyndon Words are words that are smaller by alphabetical order than any of its right subwords. Since they are Hall Words, and each word implies a unique tree structure. They are represented, for example, as

In[2]:= LyndonWordExample=LW[a,a,b,a,b,a,b,a,b]

You can check to see if a word satisfies the definition of a Lyndon Word:

In[3]:= IsLyndon[LW[a,b,a]
Out[3]= False

Note: In Java, you could replace the left or right subtree of a Lie tree by any tree, giving structures that are neither Right-Combs or Lyndon. However, the interface assumes that if it is not a Lyndon Word, it would be a Right Comb; using those Java methods (namely javatree@setLeft(or right)Subtree(new_left(or_right)_subtree)) directly in Mathematica will cause errors in calculations.


3, Free Lie Algebra elements are represented as a linear combination of Lyndon Words (LW) and Right-Combs (RComb) with an enveloping head FLn, where n is the number of generators + 1, e.g.:

In[2]:= LieAlgebraElementExample=FL3[LW[a,a,b,a,b,a,b,a,b]+3RComb[a,b,a]]

>


Algebraic Operation

1. Scalar multiplication and Addition

You could form either linear combinations of words (RComb and LW) as you would with other Mathematica expressions, or form the linear combinations and give them context by putting them under the head of FL2, FL3, FL4. The difference is that in the first case, the sum is simply formal and is the original Mathematica plus, times function, whereas in the case with the FL2(or 3 or 4) heads do the sum in the Lyndon basis.

At the moment the coefficients for the FLn elements need to be Integers. This will be replaced with rational numbers soon.

Sum of Linear combination of WordS:

In[3]:= LinCombOfWords = 2 RComb[a, b, a, b] + LW[a, b, b, a, b, b, b] - 4LW[a, b, a, b, a, b, b] - RComb[a, b, a, b] + LW[a, b, b, a, b, b, b]
Out[3]= -4 LW[a, b, a, b, a, b, b] + 2 LW[a, b, b, a, b, b, b] + RComb[a, b, a, b]


Sum of Free Lie Algebra elements (a linear combination of words wraps around

In[3]:= SumOfFL3Elements = FL3[ -4 LW[a, b, a, b, a, b, b]] + FL3[2LW[a, b, b, a, b, b, b]+RComb[a, b, a, b]]
Out[3]= FL3[-LW[a, a, b, b] - 4 LW[a, b, a, b, a, b, b] + 2 LW[a, b, b, a, b, b, b]]


Note that the FLn elements itself is not automatically reduce to the Lyndon basis form, but a sum of the FLn elements is.


2. Reduce to linear combination of Lyndon basis elements

You could reduce a single word (RComb and LW) or a Free Lie Algebra elements into a linear combination of Lyndon basis elements.

For reducing a word to Lyndon form, the word length is only limited by performance. For a good size example:

In[3]:= ReduceToLyndon[RComb[a, b, b, a, a, b, a, b, a, b, b, a, b]]
Out[3]= LW[a, a, a, a, a, a, b, b, b, b, b, b, b] + 4 LW[a, a, a, a, a, b, a, b, b, b,
    b, b, b] + 6 LW[a, a, a, a, a, b, b, a, b, b, b, b, b] + 3 LW[a, a, a, a,
      a, b, b, b, a, b, b, b, b] - LW[a, a, a, a, a, b, b, b, b, a, b, b,
      b] - 5 LW[a, a, a, a, a, b, b, b, b, b, a, b, b] - 
 7 LW[a, a, a, a, a, b, b, b, b, b, b, a, b] - 4 LW[a, a, a, a, b, a, a, b, 
     b, b, b, b, b] + 
 9 LW[a, a, a, a, b, a, b, a, b, b, b, b, b] + 9 LW[a, a, a, a, b, a, b, b, 
   a, b, b, b,
  b] - LW[a, a, a, a, b, a, b, b, b, a, b, b, b] - 10 LW[a, a, a, a, b, a, b,
      b, b, b, a, b, b] - 12 LW[a, a, a, a, b, a, b, b, b, b, b, a, b] - 2 
     LW[a, a, a, a, b, b, a, a, b, b, b, b,
  b] - 4 LW[a, a, a, a, b, b, a, b, a, b, b, b, b] + 3 LW[a, a, a, a, b, b, 
     a, b, b, a, b, b,
  b] - 2 LW[a, a, a, a, b, b, a, b, b, b, a, b, b] - 12 LW[a, a, a, a, b, b, 
     a, b, b, b, b, a, 
 b] + 2 LW[a, a, a, a, b, b, b, b, a, b, a, b, b] + 6 LW[a, a, a, a, b, b, b,
      b, a, b, b, a, b] + LW[a, a, a, a, b, b, b, b, b, a, a, b, b] + 10 LW[
     a, a, a, a,
  b, b, b, b, b, a, b, a, b] + 2 LW[a, a, a, a, b, b, b, b, b, b, a, a, b] - 
     6 LW[a, a, a, b, a, a, b, a,
  b, b, b, b, b] - 6 LW[a, a, a, b, a, a, b, b, a, b, b, b, b] + 2 LW[a, a, 
     a, b, a, a, b, b,
  b, b, a, b, b] + 8 LW[a, a, a, b, a, a, b, b, b, b, b, a, b] + 2 LW[a, a, 
     a, b, a, b, a, a,
  b, b, b, b, b] + 8 LW[a, a, a, b, a, b, a, b, a, b, b, b, b] + 4 LW[a, a, 
     a, b, a, b, a, b,
  b, a, b, b, b] - 4 LW[a, a, a, b, a, b, a, b, b, b, a, b, b] - 8 LW[a, a, 
     a, b, a, b, a, b,
  b, b, b, a, b] - 2 LW[a, a, a, b, a, b, b, a, b, a, b, b, b] - 4 LW[a, a, 
     a, b, a, b, b, a,
  b, b, b, a, b] + 2 LW[a, a, a, b, a, b, b, b, a, b, b, a, b] + 2 LW[a, a, 
     a, b, a, b, b, b,
  b, a, a, b, b] + 4 LW[a, a, a, b, a, b, b, b, b, a, b, a, b] - LW[a, a, a, 
     b, b, a, a, b, b, 
 a, b, b, b] + LW[a, a, a, b, b, a, a, b, b, b, b, a, b] - LW[a, a, a, b, b, 
     a, b, a, b, a,
  b, b, b] + 2 LW[a, a, a, b, b, a, b, b, b, a, b, a, b] - 2 LW[a, a, a, b, 
     b, b, b, a, b, a, b, a, b] + 2 LW[a, a, b, a, b, a, b, a, b, a, b, b, b]

For reducing an FLn element to Lyndon form, the word length has to be smaller than the maximum word length specified in "iniatializeHoriAssoSpace(maxWordLength)":

In[4]:= ReduceToLyndon[FL3[LW[a, a, b, a, b] + 4RComb[a, b, a, b, a, b, a]]]
Out[4]= FL3[LW[a, a, b, a, b] - 4 LW[a, a, a, a, b, b,
   b] - 4 LW[a, a, a, b, a, b, b] + 4 LW[a, a, a, b, b, a, b]]</nowiki>


Note: the two notations will probably merge.

4, Lie Brackets

Finally, you could compute the Lie bracket of two individual words (RComb and/or LW) or two Free Lie Algebra elements (FL2,3,4 elements), the results of which are reduced into the Linear combinations of lyndon words already:


In[4]:= Bracket[RComb[a, b, b, a], RComb[b, a, a, b, a]]
Out[4]= -LW[a, a, a, b, b, a, a, b, b] + LW[a, a, b, a, b, a, a, b, b]</nowiki>


In[4]:= Bracket[FL4[LW[a, b, c, a, c] + 2RComb[a, b, c, b]], FL4[-2RComb[a, b, b, c, a, b] + 4RComb[b, a, c]]]
Out[4]= FL4[8 LW[a, b, b, c, a, c, b] - 4 LW[a, b, c, a, c, a, c, b] -
   4 LW[a, b, c, a, c, b, a, c] + 4 LW[a, a, b, c, b, b, a, b, b, 
   c] + 4 LW[a, a, c, b, b, b, a, b, b, c] - 2 LW[a, a, b, c, b, 
   b, a, b, c, a, c] - 2 LW[a, a, c, b, b, b, a, b, c, a, c]]

</nowiki>