3

I am trying to balance an unbalanced chemical equation by using setting up a system of linear equations to solve for the stoichiometric coefficients in the chemical equation. After setting up a matrix, to try and solve the system, I can't because one of the matrices is a singular array.

I have taken a look at the answer at Solving systems of linear equations when matrix of coefficients is singular, but it seems like some of the answers say a system where you have a singular matrix can't be solved, while others allude to other methods. I have a very basic understanding of linear algebra, so I can't figure out how to apply some of the methods mentioned in the above question, but would like to learn how to solve systems where the singular matrix arises, since I'm sure ill come across them more than this once. My question is basically identical to Is it possible to balance a chemical equation without using trial and error?, but would like to know how to solve using the matrix method.

Here is the unbalanced chemical equation, I need to make it balanced meaning the number of atoms/molecules on each side of the $\to$ symbol is equal to the other side, e.g. there are $2\times\mathrm{Na}$ atoms of left side, only $1\times\mathrm{Na}$ on right hand side. The subscripts cant be changed, so you balance by putting a stoichiometric coefficient in front of each item, $x\mathrm{Na}$, $2\mathrm{Na}$:

$$\mathrm{Na_2CO_3(s) + HCl(aq) \to NaCl(aq) + CO_2(g) + H_2O(l)}$$

Adding stoichiometric coefficients:

$$a\mathrm{Na_2CO_3(s)} + b\mathrm{HCl(aq)} \to c\mathrm{NaCl(aq)} + d\mathrm{CO_2(g)} + e\mathrm{H_2O(l)}$$

Setting up system of linear equations:

$$ \begin{align} \mathrm{Na}&: &2a+0b-1c-0d&=0e\\ \mathrm{C}&: &1a+0b-0c-1d&=0e\\ \mathrm{O}&: &3a+0b-0c-2d&=-1e\\ \mathrm{H}&: &0a+1b-0c-0d&=-2e\\ \mathrm{Cl}&: &0a+1b-1c-0d&=0e \end{align} $$

Since I need to have a square matrix, I move the right hand side over to the left and get:

$$ A= \begin{bmatrix} 2&0&-1&0&0&\\ 1&0&0&-1&0&\\ 3&0&0&-2&1&\\ 0&1&0&0&2&\\ 0&1&-1&0&0&\\ \end{bmatrix} $$

and

$$ B= \begin{bmatrix} 0&0&0&0&0&\\ \end{bmatrix} $$

then try to solve $A^{-1}\times \det (A)\times B=$$\begin{bmatrix} a&b&c&d&e&\\\end{bmatrix}$, but then my calculator gives me a singular array error message.

andselisk
  • 266
  • 1
    You want to find the nullspace of the matrix. – Daryl Mar 07 '14 at 12:17
  • I used the function on my calculator to get the row reduced echelon form and got:

    Since i need to have a square matrix, i move the right hand side over to the left and get: $$C=\begin{bmatrix} 1&0&0&0&1&\ 0&1&0&0&2&\ 0&0&1&0&2&\ 0&0&0&1&1&\ 0&0&0&0&0&\\end{bmatrix}$$

    But still get the singular matrix error when trying to find $C^{-1}$.

    – Finding Nemo 2 is happening. Mar 07 '14 at 12:32

2 Answers2

3

Note that the setup should be as follows:

$$ \begin{align} \mathrm{Na}&: &2a+0b-1c-0d-0e&=0\\ \mathrm{C}&: &1a+0b-0c-1d-0e&=0\\ \mathrm{O}&: &3a+0b-0c-2d-1e&=0\\ \mathrm{H}&: &0a+1b-0c-0d-2e&=0\\ \mathrm{Cl}&: &0a+1b-1c-0d-0e&=0 \end{align} $$

and I get: $$ A= \begin{bmatrix} 2&0&-1&0&0&\\ 1&0&0&-1&0&\\ 3&0&0&-2&-1&\\ 0&1&0&0&-2&\\ 0&1&-1&0&0&\\ \end{bmatrix} $$

Now the coefficients $a$, $b$, $c$, $d$ and $e$ all come out positive.

andselisk
  • 266
Brad S.
  • 1,876
  • When i am presented with a chemical equation of the form $$ X_i+Yz_j+Z_k\to XYz_l+Z_m. $$

    How are you supposed to set this up, specifically concerning the signs of the numbers? I have tried doing this problem using the methods above, but just having all numbers be positive in the matrix $A$, and it gives you the "same" answer? The negative coefficients dont make sense from the chemistry side of things, so just taking the absolute value of each coefficient makes the chemical equation correct. I dont know enough about linear algebra yet, to know how the signs of numbers changes things.

    – Finding Nemo 2 is happening. Mar 08 '14 at 02:35
  • 1
    The chemical equation says so many molecules of this added to so many molecules of that react to produce...where the arrow pointing to the right represents the phrase "react to produce". When we translate the chemical equation to (several) mathematical equations, we replace the right arrow with an equal sign. Then the first step of algebra is to "move everything to one side", leaving zero on one side and everything else on the other. Of course, that makes the terms that were on the right hand side appear on the left hand side with a minus sign. – Brad S. Mar 08 '14 at 15:10
  • When you are first given the chemical equation though, and imagine the arrow acting as an equals sign, do you just let everything be positive on both sides initially? That is before moving anything to either side. So just as though you literally were swapping out the arrow for an equals sign, and not changing the sign on anything? Just everything positive...? Since i think in most if not all chemical equations you wont encounter minus signs.... – Finding Nemo 2 is happening. Mar 10 '14 at 05:26
  • 1
    Yes. That is correct. – Brad S. Mar 10 '14 at 05:39
2

As I said in my comment, you want to find the nullspace of the matrix.

A singular matrix will not have an inverse, by definition. So you will never find $C^{-1}$, because it does not exist!

Assuming your calculation is correct, from the row reduced form, you have the equivalent of the set of linear equations $$\begin{align} x_1+x_5&=0\\ x_2+2x_5&=0\\ x_3+2x_5&=0\\ x_4+x_5&=0. \end{align}$$ What you have is $x_5$ is a free variable, which means it can take any value.

From above, it should be clear that the solution is $$x=\begin{bmatrix}-x_5\\-2x_5\\-2x_5\\-x_5\\x_5\end{bmatrix}=-x_5\begin{bmatrix}1\\2\\2\\1\\-1\end{bmatrix}.$$

So, any solution of your linear system will be a multiple of $[1,2,2,1,-1]^T$. This vector forms a basis for the nullspace of the matrix.

Retturning to your application, the balance equation is $$ Na_2CO_3(s)+2HCl(aq)\to 2NaCl(aq)+CO_2(g)-H_2O(l). $$ The idea of the multiple comes in because doubling the quantity of chemicals on the left side will also scale the quantity on the right side.

Daryl
  • 5,598
  • If i have a chemical equation similar to one above, in that there are 5 different items (atoms/molecules) to solve for, but instead there are only two reactants on the left side and two products on the right side, eg: $$ aPb(NO_3)_2(aq)+bH_2S(g)\to cPbS(s)+dHNO_3(aq) $$

    I set up a $5\times 4$ matrix, then get the row reduced echelon form of: $$A=\begin{bmatrix} 1&0&0&-1/2&\ 0&1&0&-1/2&\ 0&0&1&-1/2&\ 0&0&0&0&\ 0&0&0&0&\\end{bmatrix}$$

    How do i interpret this answer?

    – Finding Nemo 2 is happening. Mar 08 '14 at 03:19
  • It seems like this is an example of a linear system with more equations than variables, if i understand correctly? Im not sure if i should start a new question or? – Finding Nemo 2 is happening. Mar 08 '14 at 03:44
  • 1
    @guydudebro You treat it in the same manner I did above. You need to find the nullspace of the matrix, which forms a basis for the solution space. In this example, you would have $x_1=x_2=x_3=2x_4$ (check this), so that a nullspace vector is $[1,1,1,2]^T$. I have chosen this one because it has integer entries, and you would usually combine an integer number of molecules. – Daryl Mar 08 '14 at 06:04
  • How did you get the $2x_4$? The fourth row is all zeroes? And what does the $T$ mean in the notation $[1,1,1,2]^{T}$? – Finding Nemo 2 is happening. Mar 10 '14 at 04:04
  • 1
    @guydudebro The $T$ is the matrix transpose. It changes this row vector into a column vector. I made a mistake with this. I will add another comment to clarify. – Daryl Mar 10 '14 at 04:14
  • 1
    You get the solution from the first three lines of the matrix, following the same technique that I described in my post. For example, from the first line, you get $x_1-(1/2)x_4=0\implies x_1=(1/2)x_4$. The same logic applies to the other lines as well gives the nullspace as to be $[1/2,1/2,1/2,1]^T$, which I gave this vector multiplied by 2. – Daryl Mar 10 '14 at 04:21