cost function plotting