Chemical Equation Balancer

Instructions

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 carrot (^) 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.

Examples



Please let me know if this is helpful or if you get any unusual errors.

The first time you balance an equation it will take longer because the applet needs to load classes. If you get any unusual error messages or errors when there shouldn't be any then please contact me. If you are interested in learning the basics of the algorithm used in this applet pease see the other page.

Does this look cool? Do you want someone to test or develop software for your website? I might be your solution. Visit the web/software consulting section of my homepage for more information.

Why does it give me more than one answer?

Every chemical equation can be balanced in an infinite number of ways. For example, 2H2 + O2 → 2H2O can also be balanced as 4H2 + 2O2 → 4H2O. In this case every balanced reaction is a multiple of the simple solution. However there are some equations where there are even more solutions! For example O + O2 → O3 (eq. 1) but also 4O + O2 → 2O3 (eq. 2). It turns out that all solutions to this particular reaction can be written as the sum of a multiple of the first equation and a multiple of the second equation. The applet always finds the smallest number of solutions so that it's possible to derive any solution from the output of the program.


Mathematical description of the solution set.

Suppose there are n chemicals in the equation. We can write any solution to the equation as an n-dimentional vector where the ith component is the coefficient to the ith compound*. Suppose x is a solution to some equation, E. As discussed above, any multiple of x is also a solution. Moreover if y is another solution then any linear combination of x and y are also solutions. Hence the set of all solutions is a vector space (the other axioms are easy to check). The applet finds a basis for this vector space. For example, when it outputs two solutions it means that the solution space is 2-dimentional and that every solution to the equation can be written as a linear combination of the two output solutions.

*One subtlety is that the coefficients that are on the products side of the reaction should be negated. This is necissary for the axioms to hold and also gives meaning to negating a solution: if x represents O + O2 → O3 then -x represents O3 → O2 + O



[Home] [Top of Page]


Copyright 2005 Berkeley Churchill. This site may be used for personal, educational, and non-commercial uses. You may not decompile the applet or make any attempt to obtain the original source code without permission from Berkeley Churchill.