In order to balance atom count in chemical equation:
a O2 + b C12H24O11 → c CO2 + d H2O
I make linear equation:
O: 2*a + 11*b = 2*c + d
C: 12*b = c
H: 24*b = 2*d
and I must find smallest positive non-zero integer that satisfy that question.
In GNU Octave I bit this problem with human interaction:
[2,11,-2,-1; 0,12,-1,0; 0,24,0,-2; 0,1,0,0]\[0;0;0;1]
ans =
12.5000
1.0000
12.0000
12.0000
[2,11,-2,-1; 0,12,-1,0; 0,24,0,-2; 0,1,0,0]\[0;0;0;2]
ans =
25
2
24
24
by searching across b coefficient until find first integer solution.
Is there any math package that find solution automatically?