Now curve_optim and cpp give the same result