  Simple analytical formulae, directly relating the experimental geometry and
sample orientation to the measured R(M)XS scattered intensity are very useful
to design experiments and analyse data. Such formulae can be obtained by the
contraction of an expression containing the polarisations and crystal field
tensors, and where the magnetisation vector acts as a rotation
derivative\cite{mirone}. The result of a contraction contains a scalar product
of (rotated) polarisation vectors and the crystal field axis. The contraction
rules give rise to combinatorial algorithms which can be efficiently treated by
computers. In this work we provide and discuss a concise Mathematica code along
with a few example applications to non-centrosymmetric magnetic systems.
