I believe your example is right, Scotty.
But, I stand corrected from my prior assumptions and examples. It appears that you must reduce the amount of qualified AOTC expenses by the amount of tax-free benefits you received during the tax year for education expenses to arrive at the net amount of taxed education expenses that can be used to claim the AOTC. Example:
I took a qualified 529 withdrawal of $20,000 for the year, of which:
-$12,000 was my contribution basis (so already taxed)
-$8,000 was tax-free growth
-$10,000 was for tuition and books (the AOTC qualified expenses)
So, on my taxes, I can only claim $2,000 ($10,000-$8,000) of taxed education expenses for the AOTC. Thus, my AOTC is only $2,000 and I miss out on the remaining $500 available AOTC maximum.
Caveat: I think this is correct, but I am not completely sure--this is based on my reading of Publication 970, and this is very complicated stuff. I am also not an accountant, so check with one (although a CPA I recently mentioned this to did not know nearly this much detail about the AOTC, since it is so new). Furthermore, it may be possible that part of the 529 withdrawal may now be taxable because of the AOTC, but I am not about to tackle how to calculate that--even more complicated. Joe, am I finally getting this right?