created log2 function for error calculation