I would suggest buying 2 gigs if that's the price they are going for, but if you don't the RAM should be compatible so long as they are the same type and same frequency (which i think is important, i' have never mixed and matched RAM so not sure).
To play it safe i would buy 2 gigs of the same type and get rid of the 512.