added cost_function.m