Introduction
Everyone who has ever studied chemistry knows that this science is complex and in many ways not completely clear. For example, middle and high school students often have problems solving chemical problems and equations. Therefore, they often look for the answer to the task with the help of chemical calculators. But most programs of this class can not be called a calculator - they do not count, but only check the result in the database. This method has a very big drawback - the program will not produce a result if the reaction equations are not in the database. Therefore, there is a need to use an algorithm that will make it possible to find the coefficients programmatically. And such an algorithm exists.
Algorithm for the arrangement of coefficients
Take for example the equation KMnO
4 + K
2 SO
3 + H
2 SO
4 -> K
2 SO
4 + MnSO
4 + H
2 O
First you need to build a matrix for it. Molecules are used as a column, atoms - as a string. The cell records the number of atoms in a molecule. We first disassemble the left side. It should turn out like this:
| KMnO 4 | K 2 SO 3 | H 2 SO 4 |
Mn | one | 0 | 0 |
K | one | 2 | 0 |
O | four | 3 | four |
S | 0 | one | one |
H | 0 | 0 | one |
Then we process the right side of the equation in the same way, but with one difference — you need to put a negative number. After this, the matrix should acquire the following form:
| KMnO 4 | K 2 SO 3 | H 2 SO 4 | K 2 SO 4 | MnSO 4 | H 2 O |
Mn | one | 0 | 0 | 0 | -one | 0 |
K | one | 2 | 0 | -2 | 0 | 0 |
O | four | 3 | four | -four | -four | -one |
S | 0 | one | one | -one | -one | 0 |
H | 0 | 0 | one | 0 | 0 | -2 |
This matrix can already be solved. But the answer we get may be correct from the point of view of mathematics, not chemistry. Therefore, one more line should be added to the matrix, in which information about the electronic balance will be recorded. In this example, it should be like this:
K
+1 Mn
+7 O
4 -2 + K
2 +1 S
+4 O
3 -2 + H
2 +1 S
+6 O
4 -2 -> K
2 +2 S
+6 O
4 -2 + Mn
+ 2 S
+6 O
4 -2 + H
2 +1 O
-2Mn
+7 + 5e -> Mn
+2S
+4 - 2e -> S
+6As you can see, Mn of the first molecule received 5 electrons, and S of the second molecule gave 2 electrons. Add another row to the matrix
| KMnO 4 | K 2 SO 3 | H 2 SO 4 | K 2 SO 4 | MnSO 4 | H 2 O |
Mn | one | 0 | 0 | 0 | -one | 0 |
K | one | 2 | 0 | -2 | 0 | 0 |
O | four | 3 | four | -four | -four | -one |
S | 0 | one | one | -one | -one | 0 |
H | 0 | 0 | one | 0 | 0 | -2 |
| five | -2 | 0 | 0 | 0 | 0 |
Now you can solve the matrix. The most convenient and fast way is
the Gauss method . The obtained data is substituted into the equation. It should turn out like this:
2KMnO
4 + 5K
2 SO
3 + 3H
2 SO
4 = 6K
2 SO
4 + 2MnSO
4 + 3H
2 O
')
findings
Thus, the coefficients for the chemical equation can be obtained without resorting to creating a database, but simply by making very simple calculations. It is also necessary to clarify that the calculation is performed extremely quickly (the delay is less than 1 ms), which makes it possible to use this algorithm not only on a PC, but also on mobile phones.