Partitioning inverse   ( 𝑆 , 𝑛 )
begin:
   𝑛 = r a n k ( 𝑆 ) ; 𝑝 = 𝑛 / 2
   𝐴 = 𝑆 [ 1 𝑝 , 1 𝑝 ] ; 𝐵 = 𝑆 [ 1 𝑝 , 𝑝 + 1 𝑛 ]
   𝐶 = 𝑆 [ 𝑝 + 1 𝑛 , 1 𝑝 ] ; 𝐷 = 𝑆 [ 𝑝 + 1 𝑛 , 𝑝 + 1 𝑛 ]
   𝑚 = size ( 𝐴 )
 if 𝑚 threshold
   𝐴 𝐴   =  Monte Carlo procedure   ( 𝐴 )
 else begin:
    𝐴 𝐴 =  Partitioning  inverse   ( 𝐴 , 𝑚 )
    𝑁 =  Partitioning  inverse   ( 𝐷 𝐶 𝐴 𝐴 𝐵 )
    𝑀 = 𝑁 𝐶 𝐴 𝐴 ; 𝐿 = 𝐴 𝐴 𝐵 𝑁
    𝐾 = 𝐴 𝐴 𝐴 𝐴 𝐵 𝑀
    𝑆 𝑆 [ 1 𝑝 , 1 𝑝 ] = 𝐾 ; 𝑆 𝑆 [ 1 𝑝 , 𝑝 + 1 𝑛 ] = 𝐿
    𝑆 𝑆 [ 𝑝 + 1 𝑛 , 1 𝑝 ] = 𝑀 ; 𝑆 𝑆 [ 𝑝 + 1 𝑛 , 𝑝 + 1 𝑛 ] = 𝑁
end
end
Algorithm 3