fixed sum in costfunctionreg
fixed sum in costfunctionreg