Q. Will I lose the remaining $1500 investment (undepreciated amount)?
A. No. You include the undepreciated amount as basis, in calculating the gain or loss.
For example, let's use $2000 as carpet cost. Let's also say the original cost of the house was $100,000 and you sold for $150,000. At the time, you sell, you had claimed $500 of depreciation on the carpet and $25,000 on the house. Your report a sale price of $150,000 and a cost basis of 102,000 (100K + 2K) for a gain of $48,000. Then you enter $25,500 (25,000 + 500) as depreciation recapture. Your total gain is $73,500 (48,000 + 25,500) of which $25, 500 is section 1250 gain (taxed as ordinary income but not more than 25%).