A native of Haining, Zhejiang, he was fascinated by mathematics since childhood, beginning with the Nine Chapters on the Mathematical Art. He eked out a living by being a private tutor for some years before fleeing to Shanghai in 1852 to evade the Taiping Rebellion. There he collaborated with Alexander Wylie, Joseph Edkins and others to translate many Western mathematical works into Chinese, including Elements of Analytical Geometry and of the Differential and Integral Calculus by Elias Loomis, Augustus De Morgan's Elements of Algebra, and the last nine volumes of Euclid's Elements (from Henry Billingsley's edition), the first six volumes of which having been rendered into Chinese by Matteo Ricci and Xu Guangqi in 1607. A great number of mathematical terms used in Chinese today were first coined by Li. He discovered the Li Shanlan’s Summation Formulae in 1867. Later he worked in the think tank of Zeng Guofan. In 1868, he began to teach in Tongwen Guan.