結果 : cost function code in python