Curve fitting with regularization