Completed lrCostFunction.m