When you say "usage" I assume you mean energy.
So you don't mean 4kw but 4Kwh. This may sound picky, but if your heat pump is rated 4kw and runs for 30 mins to heat your water up then you are using 2Kwh rather than 4Kwh.
Water has a specific heat of 4200j/kg/degree C.
So let's say you have 100 litre tank and the cold water in it is at 15 degrees C then to heat it to 40 degrees C requires :
100 (1 litre=1 kilogram) x 4200 X 25 (40-15 is 25 degrees) = 10,500,000 joules
1 million joules is 3.2 Kwh, so divide by 3,200,000 to get the joules into Kwh
=10,500,000/3,200,000 = 3.28 Kwh
You can sub in your figures to calculate how much "free" electricity your heat pump provides, as in theory the amount you use in electricity for the pump should be less than the amount of energy you should theoretically require to heat your water up.
Bear in mind there are losses of heat in the pipes, plus the pump requires some energy to run as well.