curve fitting with least squres