Duncan Gregory's great great grandfather was James Gregory and he was the youngest son of another James Gregory (1753-1821) who was professor of medicine at Edinburgh University.
Duncan was educated by his mother until he was 9 years old. His liking for constructing mechanical devices was noticed at this early age. In October 1825 he entered Edinburgh Academy (where Maxwell and D'Arcy Thompson were to be educated). He showed great promise at school and, during the winter of 1827, Duncan was sent to an academy in Geneva where his mathematical talents became apparent.
On his return from Geneva, Duncan became an undergraduate at Edinburgh University where he began to study advanced mathematical topics and he also conducted experiments with polarised light.
In October 1833, at the age of 20, Duncan Gregory entered Trinity College, Cambridge, receiving his BA in 1838 and his MA in 1841. In October 1840 he became a Fellow of Trinity and also an assistant tutor at the College.
At this time the Cambridge Mathematical Journal was starting publication and Gregory became its first editor. Many of the papers in the early parts of the Journal are written by Gregory himself.
Gregory declined a chair in Toronto in 1841 due to ill health. He returned to Edinburgh, where he was an applicant for a chair, but he died there shortly afterwards in Canaan Lodge at the age of 30.
His main contribution was his theory of algebra which he defined as the study of the combinations defined by the laws of operation to which they were subject. This is one of the first definitions of modern algebra. His work in this area is described in the paper On the real Nature of symbolic Algebra which Gregory published in the Transactions of the Royal Society of Edinburgh. In this work Gregory built on the foundations of Peacock but went far further towards modern algebra. Gregory, in his turn, had a major influence on Boole and it was through his influence that Boole set out on his innovative research.
Two other important works by Duncan Gregory are Examples of the Processes of the Differential and Integral Calculus and A Treatise on the Application of Analysis to Solid Geometry.
The first became an important text at Cambridge which, by this time, had accepted Peacock, Herschel and Babbage's Analytical Society reforms and continental methods of calculus were taught in Cambridge. The second work was unfinished at his death but completed and published the following year.