# Are matrices a good way to do stoichiometry?

I was never taught in school to use matrices to balance my equation in stoichiometry. But I recently started to review my chemistry and, as I have taken linear algebra, I was suddenly struck by the idea this would be a really efficient way to balance equations. It might save me from making a lot of errors.

Are matrices a common tool for chemists when balancing equations? Does anyone have a good reference for learning about this?

Sure, most of the equation-balancing Javascript calculators on the web use that method. It's overkill to balance a single equation that way, but if you're automating the process or if you have a lot of equations to balance and check it can be convenient.

If you search on "balancing equations matrix" you'll find many simple matrix inversion approaches for balancing equations that fail if you don't have a single unique solution. Here's one that's more general:

L. R. Thorne, An Innovative Approach to Balancing Chemical-Reaction Equations: A Simplified Matrix-Inversion Technique for Determining The Matrix Null Space, Chem. Educator 2010, 15, 304–308

The basic idea is that coefficients in balanced equations are found in the nullspace of the formula composition matrix (that is, the coefficients are solutions $$\bf x$$ of the matrix equation $$\bf C x = 0$$, if $$\bf C$$ is the formula composition matrix). For example, if I want to find a balanced equation that relates $$\rm HCl$$, $$\rm K_2Cr_2O_7$$, $$\rm FeCl_2$$, $$\rm CrCl_3$$, $$\rm H_2O$$, $$\rm FeCl_3$$, and $$\rm KCl$$, I can build a formula composition table

$$\begin{matrix} & \ce{HCl} & \ce{K2Cr2O7} & \ce{FeCl2} & \ce{CrCl3} & \ce{H2O} & \ce{FeCl3} & \ce{KCl}\cr H & 1 & 0 & 0 & 0 & 2 & 0 & 0\cr Cl & 1 & 0 & 2 & 3 & 0 & 3 & 1\cr K & 0 & 2 & 0 & 0 & 0 & 0 & 1\cr Cr & 0 & 2 & 0 & 1 & 0 & 0 & 0\cr O & 0 & 7 & 0 & 0 & 1 & 0 & 0\cr Fe & 0 & 0 & 1 & 0 & 0 & 1 & 0\end{matrix}$$

I can find the nullspace vectors using the multistep procedure outlined in that paper, or I can do it very simply in Maxima:

C : matrix([1,0,0,0,2,0,0],
[1,0,2,3,0,3,1],
[0,2,0,0,0,0,1],
[0,2,0,1,0,0,0],
[0,7,0,0,1,0,0],
[0,0,1,0,0,1,0])\$
nullspace(C);


$$\mathrm{span}\left( \begin{bmatrix}14\cr 1\cr 6\cr -2\cr -7\cr -6\cr -2\end{bmatrix}\right)$$

which corresponds to the equation

$$\ce{ 2CrCl3 + 7H2O + 6FeCl3 + 2KCl\ =\ 14HCl + K2Cr2O7 + 6FeCl2}$$

As chemists, we'd write that equation reversed,

$$\ce{ 14HCl + K2Cr2O7 + 6FeCl2\ =\ 2CrCl3 + 7H2O + 6FeCl3 + 2KCl }$$

Here are a few more nails you can pound with your linear algebra hammer: you can determine the minimum number of chemical equations required in a reaction mechanism, or discover how many equations in a reaction mechanism are stoichiometrically independent. For example, consider the following halogen/hydrogen reactions:

$$\begin{array}{rcl} \rm H_2 + X_2&\xrightarrow{k_1}&\rm 2HX\\ \rm H_2 + X_2&\xrightarrow{k_2}&\rm 2X + H_2\\ \rm H_2 + X_2&\xrightarrow{k_3}&\rm 2H + X_2\\ \rm H + X_2&\xrightarrow{k_4}&\rm X + HX\\ \rm H_2 + X&\xrightarrow{k_5}&\rm H + HX\\ \rm HX + H&\xrightarrow{k_6}&\rm X + H_2\\ \rm H_2 + HX&\xrightarrow{k_7}&\rm X_2 + H_2\\ \rm 2HX &\xrightarrow{k_8}&\rm X_2 + H_2\\ \end{array}$$

Let's make a formula matrix for the five species in the reactions above:

$$\begin{pmatrix}{H}_{2}\cr H\cr HX\cr X\cr {X}_{2}\end{pmatrix}=\begin{pmatrix}2 & 0\cr 1 & 0\cr 1 & 1\cr 0 & 1\cr 0 & 2\end{pmatrix}\begin{pmatrix}H\cr X\end{pmatrix}$$

Any set of $$S-C$$ stoichiometrically independent equations is a "complete set" of reactions, where $$S$$ is the number of species and $$C$$ is the number of independent equations for the conservation of elements (components). There are five species ($$S=5$$) and the rank of the formula matrix is 2, so the system has two components ($$C=2$$). There must be $$S - C = 5 - 2 = 3$$ stoichiometrically independent reactions for the mechanism to be complete.

Do the reactions above constitute a complete set? We can write a stoichiometric matrix like so:

$$\begin{pmatrix}-1 & 0 & 2 & 0 & -1\cr 0 & 0 & 0 & 2 & -1\cr -1 & 2 & 0 & 0 & 0\cr 0 & -1 & 1 & 1 & -1\cr -1 & 1 & 1 & -1 & 0\cr 1 & -1 & -1 & 1 & 0\cr 0 & 0 & 0 & -2 & 1\cr 1 & 0 & -2 & 0 & 1\end{pmatrix} \begin{pmatrix}{H}_{2}\cr H\cr HX\cr X\cr {X}_{2}\end{pmatrix} = \begin{pmatrix}0\cr 0\cr 0\cr 0\cr 0\cr 0 \cr 0 \cr 0\end{pmatrix}$$

The rank of the stoichiometric matrix is 3, so the eight equations above are equivalent to three independent equations. The mechanism is complete. Whether it's correct is of course a different matter. Stoichiometric constraints don't determine a mechanism; they limit the number of reactions in a particular reaction channel, but you can have more than one channel (more than one mechanism running side-by-side).

Why is this useful---why would you want to know what the number of independent stoichiometric equations ($$R$$) are? Well, according to Gibb's rule of stoichiometry, $$R \le S-C$$. If you have $$R < S-C$$, that tells you that you have a restricted equilibrium: the components must be constrained by conditions other than stoichiometric equations. The restricted equilibrium composition will depend on which species are present initially in that case. There are also experimental design implications, since in a single experiment you can get only $$S-C$$ reaction rates. You may have to figure out how to favor one channel over another in separate experiments to get all of the rates.

TL;DR: If you're looking for applications of linear algebra in chemistry, chemical kinetics is one playground; there are many others.

• Thanks for the article. It was just along the lines of what I was hoping for. – Stan Shunpike Jan 27 '15 at 19:11
• Very nice answer Fred. I believe Leons book on linear algebra includes examples where such systems of equations are worked out. If OP wants, I can upload them for him. – Jori Jan 29 '15 at 16:05
• @Jori that would be fantastic – Stan Shunpike Jan 29 '15 at 21:01