Balance chemical equations without trial and error?

In my AP chem class, I often have to balance chemical equations like the following:

$$\text{Al} + \text O_2 \to \text{Al}_2 \text O_3$$

The goal is to make both side of the arrow have the same amount of atoms by adding compounds in the equation to each side.

A solution:

$$4 \text{Al} + 3 \text O_2 \to 2 \text{Al}_2 \text O_3$$

When the subscripts become really large, or there are a lot of atoms involved, trial and error is impossible unless performed by a computer. What if some chemical equation can not be balanced? (Do such equations exist?) I tried one for a long time only to realize the problem was wrong.

My teacher said trial and error is the only way. Are there other methods?

-
Are you being serious, or just seeding the site? –  Casebash Jul 24 '10 at 3:20
@Casebash: I would guess the latter, but why does it matter? This is a math question, albeit a simple one. –  Larry Wang Jul 24 '10 at 3:28
it's also probably one of the more useful math questions for high school chem! If I had a nickel for every chem student I've tutored whose teacher told them they just had to try coefficients til it worked... –  Jamie Banks Jul 24 '10 at 3:55

Yes; it's possible to write a system of equations that can be solved to find the correct coefficients. Here's an example for the given formula.

We're trying to find coefficients A, B, and C such that

A (Al) + B (O_2) -> C (Al_2 O_3)


In order to do this, we can write an equation for each element based on how many atoms are on each side of the equation.

for Al:  A = 2C
for O:  2B = 3C


This is an uninteresting example, but these will always be linear equations in terms of the coefficients. Note that we have fewer equations than variables. This means that there's more than one way to correctly balance the equation (and there is, because any set of coefficients can be scaled by any factor). We just need to find one integral solution to these equations.

To solve, we can arbitrarily set one of the variables to 1 and we'll get a solution with (probably fractional) coefficients. If we add $A=1$, the solution is $(A,B,C) = (1,3/4,1/2)$. To get the smallest solution with integer coefficients, just multiply by the least common multiple of the denominators (4 in this case), giving us $(4,3,2)$.

If the set of equations has no solution where the coefficients are nonzero, then you know that the equation cannot be balanced.

-
Ben: I think you left out the most important part: How to solve those two equations! –  Larry Wang Jul 24 '10 at 3:42
I agree with Kaester; it appears that your mathematical form, with two equations and three unknowns, reduces to guess and check just as well! –  Justin L. Jul 25 '10 at 0:23
Just edited; better now? –  Ben Alpert Jul 25 '10 at 1:00
thx, I changed the solution in the answer, idk what i was thinking xD –  Chao Xu Jul 25 '10 at 2:31