Implementation for both the 2x2 and 3x3 formulations