On his return to Scotland, he attended classes at the University of Edinburgh, working at chemistry, making experiments in polarised light, and advancing in the higher parts of mathematics, guided by Professor Wallace, his mentor.
[2] Gregory was initially recognised for his essay The Foundations of Algebra presented to the Royal Society of Edinburgh in 1838.
[4][5] Many of his articles for the CMJ were collected in The Mathematical Writings of D. F. Gregory, edited by his friend and colleague William Walton.
In 1841 he published his Examples of the Processes of the Differential and Integral Calculus, which expanded the earlier work of John Herschel, George Peacock and Charles Babbage to include the mathematics used to describe discontinuities observed in heat transfer explored by the French mathematician Joseph Fourier, and the theory of undulatory light, a topic familiar to him.
[9] Gregory is buried with his siblings in his parents burial plot in the south-west corner of Canongate Kirkyard, next to Adam Smith.
Gregory lived together with his brothers and their wives in a huge Georgian townhouse, 10 Ainslie Place, on the Moray Estate in the western New Town of Edinburgh, originally their father's house.