The fundamental formula
i² = j² = k² = ijk = -1of the theory of quaternions came to Hamilton as he was walking with his wife from Dunsink Observatory to Dublin along the Royal Canal on 16th October, 1843. He carved this formula on a stone of Broome Bridge. He describes the circumstances in a letter to one of his sons, Rev. A.H. Hamilton, and in a letter to Professor P.G. Tait.
Hamilton described the train of thought that led to his discovery in a letter to John T. Graves, who had been a fellow student with Hamilton at Trinity College, Dublin.
On the 13th November, 1843 he presented a paper, On a new Species of Imaginary Quantities connected with a theory of Quaternions, at a meeting of the Royal Irish Academy describing his discovery.
Almost a year later, on the 11th November, 1844, he presented another paper, On Quaternions, at a meeting of the Royal Irish Academy.
A full account of Hamilton's early research on quaternions is to be found in the paper Researches respecting Quaternions, First Series, which was published in volume 21 of the Transactions of the Royal Irish Academy
Hamilton subsequently published many papers developing the theory of quaternions, including a substantial paper On Quaternions, or on a New System of Imaginaries in Algebra, published in installments in the Philosophical Magazine in between 1844 and 1850. He also developed a `coordinate-free' approach to the subject in another paper, On Symbolical Geometry, which appeared in installments in the Cambridge and Dublin Mathematical Journal between 1846 and 1849. His Lectures on Quaternions were published in 1853. (This book has 736 pages.) A second book, the Elements of Quaternions was almost complete at the time of his death.