結果 : how to implement cost function in python