The Math Behind the Motifs