I have written a small utility for balancing chemical equations:
https://hackage.haskell.org/package/chemical-equation
Example:
$ balance-chemical-equation CH4 O2 CO2 H2O
CH4 + 2 O2 <=> CO2 + 2 H2O
The solution requires determining the nullspace of an integer matrix where
the nullspace must also be expressed in integer vectors. The default
solver computes the Reduced Row Echelon Form in Haskell using lists and
Rational. An alternative solver uses the FLINT library and can be enabled
with the Cabal flag 'flint'. My first attempt using LAPACK can be tried
with the Cabal flag 'lapack'. LAPACK's LU decomposition however cannot
handle rank deficient matrices, thus the solver fails on some equations.