Initial commit of error minimization algo.