Thanking fellow PhD students in a paper
The acknowledgements section of a paper is a perfect place to thank people who significantly aided you with the paper, but not to the level where authorship is merited.  

Unlike the acknowledgements of your thesis, however, the tradition of such sections is generally to be somewhat more strict in the notion of direct and material contributions: you should not be thanking your dog here.  So, for example, if your officemate actually read and critiqued the paper, acknowledgement is appropriate, but if they just helped to keep your spirits up, acknowledgement is not appropriate.

(I am answering from the general traditions of computer science, which are related but may not be quite the same as your area of mathematics)