update how to calculate matrix ^ n