For the initial purchase, Geraldine already has the gain of 
$40,000 - $20,000 = $20,000 
Because he succcesfully bought the land below the market value.
After the sale, the total gain would be
$20,000 + ($45,000 - $20,000)
$20,000 + $ 25,000
= $45,000