Linear algebra for balancing chemical reaction equations

The balancing of chemical reaction equations is familiar for many, either from high school chemistry or introductory university chemistry. A simple example of such a problem is the reaction equation for the combustion of methane in oxygen:

aCH_4 + bO_2 \rightarrow cCO_2 + dH_2 O,

for which we are supposed to find coefficients a,b,c and d that make the reaction possible in terms of conservation of the number of atoms of any element that is present. In this case, it is rather easy to see that the number of CO_2 molecules must be equal to the number of CH_4 molecules, and that the number of water molecules must be twice that. Therefore the possible equations are

CH_4 + 2O_2 \rightarrow CO_2 + 2H_2 O , or

2CH_4 + 4O_2 \rightarrow 2CO_2 + 4H_2 O, or

3CH_4 + 6O_2 \rightarrow 3CO_2 + 6H_2 O ,

or any other “multiple” of the first equation (obtained by multiplying all the coefficients in the equation with the same number).

Usually this kind of balancing is done mainly by intuition and trying to guess the right coefficients, but this can be difficult if the reactants and product contain many different elements, each of which are present in more than one kind of molecule. One example of a more complicated (but still quite simple) reaction is the reaction of chlorine dioxide (ClO_2) with alkaline water to form chlorate (ClO_3^-), chlorite (ClO_2^-) and water:

aClO_2 + bOH^- \rightarrow cClO_2^- + dClO_3^- + eH_2 O .

Now, an easily applicable way to solve a set of acceptable coefficients a,b,c,d and e is to explicitly write the balancing condition equations for each element that appears in the equation. These balancing conditions are:

a = c + d                                 (balancing of chlorine)
2a + b = 2c + 3d + e             (balancing of oxygen)
b = 2e                                   (balancing of hydrogen)
b = c + d                                (balancing of electric charge)

This can be solved with many kinds of mathematical software, either free (there’s lots of free math programs especially for Linux) or commercial (like Wolfram Mathematica).

But there’s one another thing. Because the number of unknowns in the system of equations above is larger than the number of equations by one, we need to decide the value of one of the coefficients a, \dots , b arbitrarily. So let’s say that a = 1. Now the set of equations is:

a = 1                                   (arbitrary choice of one coeffiecient)
a = c + d                            (balancing of chlorine)
2a + b = 2c + 3d + e          (balancing of oxygen)
b = 2e                              (balancing of hydrogen)
b = c + d                           (balancing of electric charge)

Using the column vector


the system of equations can be written in matrix form


This can be solved in Mathematica by writing the command

Solve[{a == 1, a == c + d, 2a + b == 2*c + 3*d + e, b == 2e, b == c + d}]

and the result is

a = 2,

b = 2,

c = 1,

d = 1,

e = 1,
which leads to the reaction equation

2ClO_2 + 2OH^- \rightarrow ClO_2^- + ClO_3^- + H_2 O

which doesn’t even need to be multiplied with any constant to make all the coefficients integers (usually that is necessary).
IMAGE SOURCE: The feature image of an Erlenmeyer flask on this blog post is a public domain image from Wikipedia, address .