added matrix chain multiplication efficiency functions