An associator is a formal power serie in two noncommuting variables
If
where the
There are two fundamental results of Drinfeld about associators. First of all, associators does exists, which is not obvious at all. This is proved by analytic methods, and the resulting associator has transcendental coefficients (which are multizeta values). Secondly, he proved that a rational, even associator exists. Here even mean that each of its odd degree homogoneous part has zero coefficient. Although no explicit formula is known for such an associator, it can be computed recursively in the following way: assume that we know an element
The theorem of Drinfeld asserts that this equation can always be solved, i.e. that it is always possible to extend an associator up to degree
Actually, there is a whole family of algebras
The following files contains the implementation of two algebraic structures. Note that according to the SAGE philosophy, they are in particular free modules meaning that we get for free a lot of usefull SAGE procedure dealing with linear algebra. The only things we have to do is to constructs a basis, and to define the product of two basis elements. The product is extended linearly automatically. The first structure is a class for

and construct the algebra

Recall that there are free modules, hence all corresponding SAGE functions are available
(423, 31) 

A rewriting algorithm is automatically applied to put elements in a normal form. A using a nice feature of Python, the product is a "cached method", meaning that the product of two given elements is computed only once and stored in memory for further use. The basis of
B[word: ] + 45*B[word: t12,t13,t23,t34] + 10*B[word: t12,t13,t34]  45*B[word: t12,t13,t34,t24] + 45*B[word: t12,t13,t24,t34] + 45*B[word: t12,t23,t13,t34]  90*B[word: t12,t23,t34,t14] + 90*B[word: t12,t23,t14,t34]  10*B[word: t12,t34,t14] + 45*B[word: t12,t34,t24,t14]  45*B[word: t12,t24,t34,t14] + 10*B[word: t12,t14,t34]  45*B[word: t12,t14,t34,t24] + 45*B[word: t12,t14,t24,t34] + 10*B[word: t23] + 45*B[word: t23,t23] + 120*B[word: t23,t23,t23] + 210*B[word: t23,t23,t23,t23]  45*B[word: t23,t13,t13,t34] + 45*B[word: t23,t13,t34,t14]  45*B[word: t23,t13,t14,t34] + 45*B[word: t13,t23,t13,t34]  45*B[word: t13,t23,t34,t14] + 45*B[word: t13,t23,t14,t34] CPU time: 0.18 s, Wall time: 0.18 s 
So our algebra

Now SAGE can turn it into a module map

It is easily seen that the hexagon equation implies that the first terms of

Now we expand the pentagon equation and store the defect
1/576*B[word: t13,t23,t24,t14]  1/576*B[word: t23,t13,t24,t14] + 1/576*B[word: t23,t13,t14,t24] + 1/576*B[word: t24,t14,t34,t14] + 1/576*B[word: t24,t14,t34,t24]  1/576*B[word: t24,t14,t14,t34]  1/192*B[word: t24,t14,t24,t34]  1/576*B[word: t34,t14,t24,t24]  1/288*B[word: t34,t14,t24,t34]  1/576*B[word: t34,t24,t24,t14]  1/576*B[word: t34,t24,t34,t14] + 1/192*B[word: t34,t24,t14,t24] + 1/192*B[word: t34,t24,t14,t34] + 1/576*B[word: t34,t24,t14,t14]  1/576*B[word: t34,t34,t24,t14] + 1/576*B[word: t34,t34,t14,t24] + 1/576*B[word: t14,t24,t34,t14] + 1/576*B[word: t14,t24,t34,t24] + 1/576*B[word: t14,t24,t14,t34] + 1/576*B[word: t14,t24,t24,t34] + 1/576*B[word: t14,t24,t34,t34] + 1/576*B[word: t14,t14,t34,t24]  1/576*B[word: t14,t14,t24,t34]  1/576*B[word: t14,t34,t24,t24]  1/288*B[word: t14,t34,t24,t14] + 1/576*B[word: t24,t34,t34,t14]  1/576*B[word: t24,t34,t14,t24]  1/576*B[word: t24,t34,t14,t14]  1/576*B[word: t24,t34,t14,t34]  1/576*B[word: t24,t34,t24,t14]  1/576*B[word: t24,t14,t34,t34] + 1/576*B[word: t24,t24,t34,t14] + 1/576*B[word: t24,t24,t14,t34]  1/576*B[word: t13,t23,t14,t24] CPU time: 0.04 s, Wall time: 0.04 s 
We construct the matrix of the above linear map. Note that it can be done in a quite elegant way thanks to the list comprehension feature of Python

We can have a look on the kernel of
[B[word: aab]  2*B[word: aba]  B[word: abb] + B[word: baa] + 2*B[word: bab]  B[word: bba], B[word: ab]  B[word: ba]] 
It means that the kernel in degree 4 is zero, so that our associator is, up to now, uniquely determined. The kernel in degree too is (linearly) spanned by
Now we get the coordinates of the defect in the pentagon equation, and try to solve the corresponding equation
1/1440*B[word: aaab] + 1/480*B[word: aaba] + 1/5760*B[word: aabb]  1/480*B[word: abaa] + 1/1920*B[word: abab]  1/1152*B[word: abba]  1/1440*B[word: abbb] + 1/1440*B[word: baaa]  1/1152*B[word: baab] + 7/5760*B[word: baba] + 1/480*B[word: babb]  1/5760*B[word: bbaa]  1/480*B[word: bbab] + 1/1440*B[word: bbba] 
We update our definition of Phi

We check all the relations
0 B[word: ] B[word: ] 
and we know that
+1/24['a', 'b'] 1/1440['a', ['a', ['a', 'b']]] +1/5760['a', [['a', 'b'], 'b']] 1/1440[[['a', 'b'], 'b'], 'b'] 
Now let's go the the degree 6. First, redefine our algebras:

The construction of the matrix begin to be quite hard. On the other hand, this requires to compute the images of each basis elements of

No we define a function which will split into 16 independant process. Note that unlike what we did just a few lines before, the parameter of the function is an indice and not directly a basis element. It will help us to keep track of the order of the list.

Now we apply this function to the list (0,...,size of the basis). The computation are not done at this point ! This returns a Python object called an "iterator", and computation will be done on demand.

Now we create a list listMat of the right size but filled with zeros, and loop over L. Then we fill listMat by putting each vector at its right place. Elements of the iterator are of the form, hence elt[0][0][0] contains the indice, and elt[1] the result of the computation. The Python syntax is really natural for a mathematician: if l1 and l2 are two lists, l1+l2 is the concatenation of them, hence N*l1 where N is a natural integer is the concatenation of N copies of l1.
CPU time: 6.54 s, Wall time: 35.86 s 
Now we expand the pentagon
CPU time: 1.40 s, Wall time: 1.40 s 




+1/24['a', 'b'] 1/1440['a', ['a', ['a', 'b']]] +1/5760['a', [['a', 'b'], 'b']] 1/1440[[['a', 'b'], 'b'], 'b'] +1/60480['a', ['a', ['a', ['a', ['a', 'b']]]]] 1/80640['a', ['a', ['a', [['a', 'b'], 'b']]]] +17/1451520['a', [['a', ['a', 'b']], ['a', 'b']]] +23/967680['a', ['a', [[['a', 'b'], 'b'], 'b']]] +1/725760['a', [['a', 'b'], [['a', 'b'], 'b']]] 199/5806080[['a', [['a', 'b'], 'b']], ['a', 'b']] 1/80640['a', [[[['a', 'b'], 'b'], 'b'], 'b']] 19/1451520[['a', 'b'], [[['a', 'b'], 'b'], 'b']] +1/60480[[[[['a', 'b'], 'b'], 'b'], 'b'], 'b'] 

Vector space of degree 127 and dimension 3 over Rational Field Basis matrix: 3 x 127 dense matrix over Rational Field 
+1['a', ['a', ['a', ['a', 'b']]]] 2['a', ['a', [['a', 'b'], 'b']]] +3/2[['a', ['a', 'b']], ['a', 'b']] +2['a', [[['a', 'b'], 'b'], 'b']] +1/2[['a', 'b'], [['a', 'b'], 'b']] 1[[[['a', 'b'], 'b'], 'b'], 'b'] None +1['a', ['a', 'b']] 1[['a', 'b'], 'b'] None +1['a', 'b'] None 
