This is a java program for CLI. The source is here, chembal.tar. If you want just a .jar file to run, you can use chembal.jar.

Originally this software was designed to run in an ancient browser technology known as a "Java applet". If you've never heard of this, you're fortunate. The CLI version strips out all this functionality.

To balance a reaction simply list all the reactants and products. Seperate different compounds with + signs. To add a charge, simply follow the chemical by a caret (^) and then the charge. If the charge is positive you should leave off the + sign before the charge, but if it's negative it should be prefixed by a - sign.

- Cu + HNO3 + Cu(NO3)2 +NO+H2O
- H2O + H^ + Cl^- + MnO4^- + Cl2 + Mn^2
- H2 + O2 + H2O
- Na2CO3 + HCl --> NaCl + CO2 + H2O
- O + O2 --> O3
- Na2CO3 + HCl + FeCl3 + Fe2O3 + NaCl + H2O + CO2

You can get multiple solutions to a reaction if there is more than one way to balance it (where taking multiples of all the coefficients does not count as a separate way). In the language of linear algebra, the applet outputs a "basis" for all the solutions.

The program automatically tries to put the arrow in a sensible place so that the reaction balances properly. It can do things that make no sense if there are multiple solutions. You will need to take linear combinations of the solutions yourself to get the arrow in the right place.

Consider this example: H_{2} + O_{2} --> H_{2}O. Using algebra, we will make a system of equations to solve the chemical equation. Let's force the coefficient of H_{2} to be *a*, the coefficient of O_{2} to be *b* and the coefficient of H_{2}O to be *c*. Then since there are the same number of hydrogen atoms on each side of the chemical equation, we know that *a* = *c*. Since there are the same number of oxygen atoms on each side, *b* = 2*c*. Notice that *a* = 2, *b*=1 and *c* = 2 is a solution to this system. It is not the only one, but it is the "smallest" one that uses positive integers. Therefore the balanced reaction is 2H_{2} + O_{2} --> 2H_{2}O. The applet above does this same process, except on a larger scale, using the tools of linear algebra.

List the compounds in the chemical reaction, and call them *c*_{1}, *c*_{2}, ... , *c*_{n}. Let the integer *a _{i}* denote the number of occurences of

These equations may be put into matrix form, Bx = 0. In simple terms, the applet solves this system of equations and returns the answer. However, it's not really that simple. Obviously, x = 0 is a solution to the above matrix equation. But if y ≠ 0 and By = 0 then B(my) = 0 for any scalar m. This means the system has one solutions, or infinitely many. If there is only one solution, the chemical equation does not balance. If all the solutions to the equations are scalar multiples of each other, then choosing any one is fine, since one may multiply both sides of a chemical equation by a scalar. It gets trickier when the solutions are not scalar multiples of each other. In linear algebraic terms, the applet finds a basis for the vector space of solutions to the matrix equation and outputs each basis vector as a chemical equation. Thus, when you get an output with multiple answers, this means you can add and subtract these chemical equations in order to produce any way to balance the equation. This happens when two reactions are happening simultaneously but independently; however there are more complicated situations where this happens as well.