This kind of cost function is mostly used in cases where you have a functions that predicts real numbers based on certain input variables.
For example
I have seen this kind of cost functions being used with