Code taking too long time to compute

My Mathematica code is taking too much time to compute. I don’t know what the issue is. Can anyone suggest any changes that I need to make in order for the code to work?

Ananth Krishna V

Your computeEntropy function gives complex outputs. This way the condition Abs[Snew - Sold]/Snew < tolerance never becomes True, because Snew is complex.