# Why does the coefficient of performance need to be calculated with $W + Q$?

How much work must a heat pump with a COP of 2.50 do in order to extract 1.00 MJ of thermal energy from the outdoors (the cold reservoir)?

The first formula that came into my mind after reading this question is the

$$COP=\frac{\lvert Q(\text{cool})\rvert}{\lvert W\rvert}$$

However, when I used the equation above, the answer that I got was 0.4 MJ instead of the answer given which is 0.67 MJ.

And then I tried various other ways to try and get the 0.67 MJ and only when I used this equation that I finally get the answer 0.67 MJ.

$$COP=\frac{\lvert W+Q(\text{cool})\rvert}{\lvert W\rvert}$$

What I don't understand is that why do we need to add $W$ with $Q$? Or is it not the correct way after all?

Would somebody explain this to me, please?

By definition, the COP of a heat pump or a refrigerator is the 'useful' heat carried by the machine divided by the 'work' consumed by the machine. A refrigerator lifts heat $Q_c$ from a cold reservoir (the cold box) at an expense of external work $W$, and dumps this $Q_h = Q_c + W$ into a hot reservoir. The 'useful' heat carried in this case is $Q_c$ and hence $COP = Q_c/W$. On the other hand, a heat pump picks heat $Q_c$ from a cold atmosphere, again at an expense of external work $W$ and dumps $Q_h = Q_c + W$ into the space which is to be heated. Hence the 'useful' effect in case of a heat pump is $Q_h$. Therefore, the COP of a heat pump is defined as $COP = Q_h/W = (Q_c + W)/W$.