What should one do before submitting a paper? Assume I just wrote a paper. Now I would like to publish it in a journal.
What kind of things I should do before its submission?
Should I first give a few talks at seminars or conferences? Upload to arxiv? Send to a few experts?
What is the best algorithm?
 A: First of all, upload to the arxiv. Then you can write to the experts you know, and inform them that you uploaded your new paper. Then wait a little to give them opportunity to send you comments. If there is a possibility, give seminar/conference talks, but it is not necessary to do this before you send it
to a journal.
Edit. Posting the paper in the arxiv is really the most important step. See the comment of Timothy Chow for many reasons of this. From the point of view of
dissemination of the result, it is more important than publishing it in a journal. Some people who do not care about grants and promotions even do not bother to send their results to journals.
A: First of all, proofread it several times. Remember that every minor mistake that will take you five minutes to correct may perplex the reader for several hours, so aim at minimizing the community time, not just your own time.
Second, check that all references that you use in an essential way are easily accessible and contain full proofs, not just further references to endless "trees of knowledge". Remember that the full length of your paper is the sum of the pages in the main text, the texts you refer to, the texts the texts you refer to refer to, and so on until you reach some "common knowledge" layer (what exactly constitutes it depends on whom you are writing for, but don't aim just at "experts").
Third, show it to some knowledgeable people you trust and discuss with them both the content and the readability. You may get some useful feedback on both accounts.
Then, if everything looks good, place it on arXiv and send the link to the people who you believe may be interested. Meanwhile think of where you would like submit it. Once you have made your choice, submit following the chosen journal procedure (you can usually find all the requirements, style files, etc. on the journal webpage).
Once you get a referee report, see what you agree with and what you disagree with. Remember 2 things. First, the referees see your paper with the "reader eyes" as opposed to "author eyes" you see it with, so if they stumble somewhere and say that they would appreciate a clarification, then, most likely, some other readers will appreciate it too even if it looks crystal clear to you. Second, the referees are not all-powerful and omniscient gods, so it is totally OK to disagree with them both about mathematics and about stylistic issues. If you think that some referee suggestion is totally outlandish or stems from complete misunderstanding of what was written, you are by no means obliged to follow it. Just explain in the letter to the editor why you think so.
Once you get the galley proofs, go over them and compare with the submitted text. Check that all technical editor corrections make sense (usually they are minor, but even a minor change can alter the meaning of a sentence sometimes). If you are happy with everything, that's the end: the paper is out for publication and you do not need to do anything else. If not, report the needed corrections to the editor. Usually they just accept them at that stage.
That's the full process from the beginning to the end as I see it.
