411 REFERENCE · Wikibooks
Linear Algebra and the C Language/a087
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
__NOTOC__
Balancing a chemical equation
a) The system:
double ab[RA*(CA+C1)]={
// x1 x2 x3 x4 b
+0, +0, -0, -0, 0, //C
+0, +0, -0, -0, 0, //H
+0, +0, -0, -0, 0, //O
};
Each coefficient must have a column. Here four coefficients therefore four columns.
Each atom must have a row. Here, three atoms, so three rows.
The coefficients on the left side of the chemical equation must have a positive coefficient. (x1, x2)
The coefficients on the right side of the chemical equation must have a negative coefficient. (x3, x4)
b) The first column:
double ab[RA*(CA+C1)]={
// x1 x2 x3 x4 b
+1, +0, -0, -0, 0, //C
+4, +0, -0, -0, 0, //H
+0, +0, -0, -0, 0, //O
};
x1 is related to two atoms C and H.
There is one C that we write in the first column of the first row.
There are four H that we write in the first column of the second row.
c) The second column:
double ab[RA*(CA+C1)]={
// x1 x2 x3 x4 b
+1, +0, -0, -0, 0, //C
+4, +0, -0, -0, 0, //H
+0, +2, -0, -0, 0, //O
};
x2 is related to one atome O.
There are two O that we write in the second column of the third row.
d) The third and the fourth columns: (With negative coefficients)
double ab[RA*(CA+C1)]={
// x1 x2 x3 x4 b
1, 0, -1, -0, 0, //C
4, 0, -0, -2, 0, //H
0, 2, -2, -1, 0, //O
};
Now we need to introduce this system into the file:
c00a.c.