isolating the procedure to generate the height function
isolated the procedure to plot the cost function