How to find the right additive polynomial in inverse affine transformation in AES
The Affine Transformation for AES Sbox is given by



Let M b the 8x8 binary matrix and C be the affine additive constant then 

B = M x A xor C --------------- (1)

The straight forward reverse to this transformation is



A = M-1 * ( B xor C ) --------------- (2)

Where as the inverse of Affine Transformation is given as



Let D be the additive constant used in above inverse affine transformation then

A = ( M-1 x B ) xor D --------------- (3)

Place value of B from (1) in (3)

A = ( ( M-1 x (M x A xor C ) ) xor D

A = ( ( M-1 x M x A) xor ( M-1 x C ) ) xor D

Multiplying M with M-1 will be Identity, thus

A = A xor (M-1 x C) xor D

this implies

D = M-1 x C

and thats how the additive constant in inverse affine transformation have been calculated.

in fact it is