His earliest work dealt mainly with mathematical subjects, and especially with quaternions (q.v.), of which he may be regarded as the leading exponent after their originator, Hamilton.
He was the author of two text-books on them - one an Elementary Treatise on Quaternions (1867), written with the advice of Hamilton, though not published till after his death, and the other an Introduction to Quaternions (1873), in which he was aided by Professor Philip Kelland (1808-1879), who had been one of his teachers at Edinburgh.
In addition, quaternions was one of the themes of his address as president of the mathematical section of the British Association in 1871.
Among his articles may be mentioned those which he wrote for the ninth edition of this Encyclopaedia on Light, Mechanics, Quaternions, Radiation and Thermodynamics, besides the biographical notices of Hamilton and Clerk Maxwell.
Under the general heading "Fundamental Notions" occur the subheadings "Foundations of Arithmetic," with the topics rational, irrational and transcendental numbers, and aggregates; "Universal Algebra," with the topics complex numbers, quaternions, ausdehnungslehre, vector analysis, matrices, and algebra of logic; and "Theory of Groups," with the topics finite and continuous groups.