Multiple twinning in cubic crystals is represented geometrically by a threedimensional fractal and algebraically by a groupoid. In this groupoid, the variant crystals are the objects, the misorientations between the variants are the operations, and the AE3 n operators are the different types of operations (expressed by sets of equivalent operations). A general formula gives the number of variants and the number of AE3 n operators for any twinning order. Different substructures of this groupoid (free group, semigroup) can be equivalently introduced to encode the operations with strings. For any coding substructure, the operators are expressed by sets of equivalent strings. The composition of two operators is determined without any matrix calculation by string concatenations. It is multivalued due to the groupoid structure. The composition table of the operators is used to identify the AE3 n grain boundaries and to reconstruct the twin related domains in the electron back-scattered diffraction maps.