> def mycost(c): > y_model = c[0] + c[1]**x > error_vect = y - y_model > return sum(error_vect**2) > FWIW norm(errorvect) will probably be faster than explicit summing and squaring.