After attending the Academy at Edinburgh and spending a session at the University, he went up to Cambridge as a member of Peterhouse, and graduated as senior wrangler and first Smith's prizeman in 1852.
Before he was sixteen he attended lectures at Owens College, and at eighteen he gained a mathematical scholarship at Trinity College, Cambridge, where he graduated in 1871 as senior wrangler and first Smith's prizeman, having previously taken the degree of D.Sc. at London University and won a Whitworth scholarship. Although elected a fellow and tutor of his college, he stayed up at Cambridge only for a very short time, preferring to learn practical engineering as a pupil in the works in which his father was a partner.
At London University in 1849, and was Hebrew and New Testament prizeman in 1850 and gold medallist in philosophy in 1854.
At Cambridge, Leonard Courtney was second wrangler and first Smith's prizeman, and was elected a fellow of his college, St John's.
In 1843 as the senior wrangler and first Smith's prizeman of his year.
His father, John Martyn, was a "captain" or mine-agent at Gwennap. The lad was educated at Truro grammar school under Dr Cardew, entered St John's College, Cambridge, in the autumn of 1797, and was senior wrangler and first Smith's prizeman in 1801.