The loss function used in regression is called mean squared error

where:

Incorporating that loss function into the cost function :