This is another thread comment which provides you hint screenshot given in the assignment
you are suppose to first initiate cost with a value.
then in iteration for range m, your equation f_wb need to be recalled, then f_wb will be next implemented in the same iteration to the cost you initialised at beginning(remember it is cost and not total cost.
Then this cost is used to calculate the total cost with the implementation ((1/2*m)*cost which gives your total cost values