Affiliation on a paper - moving to a place where I actually did the work Me and a person from University X wrote a (pure mathematics) paper together. Most of the work on this paper happened when I was visiting University X during last summer (they were kind enough to provide a room for me and invite me to give a seminar). It is also worth mentioning that X is located where I come from, so given that I can be quite mobile in my work, I would probably be spending most of the summer there in any case. I am currently a PhD student at University Y, located abroad, and I'm just about to finish my degree. Once this happens, I am going to sign a contract with X (the paperwork is waiting until I graduate).

Now that the paper is finished, I wonder what affiliation it would be ethical of me to mention on the paper. It goes without saying that I should mention Y - that's where my position is at the moment, they are the people giving me funding. However, I would also be happy to mention X - there are various reasons why I would want that, some more valid than other. Would it be right of me to do so?
The way this is usually handled is that you list University Y as your affiliation, and in the acknowledgements of the paper, include a sentence that says something like:


  Much of this paper was written while the second author was visiting University X; he would like to thank the X Department of Mathematics for their hospitality and support.


If you end up doing significant further work on the paper after you start your job at X (e.g. major revisions in response to peer review), then you could list both universities as your affiliation.