Yah I know of an algorithm. Just like buying a car.
Buy it brand new and lose about %20 immediately. Keep it four years and it's more valuable for collecting dust then trying to box it up and sell it.
I've heard more then once, but have never confirmed, that if you donate a computer within two years of the initial purchase, you can write off 100% of the original value, but I've never looked into it. Supposedly a few years back there was a program in my hometown to do just that by donating to financially strapped schools, and lower-income families.
So, a $2000 computer in two years with a tax bracket of 33% would let you save ~$600 on your taxes.