How would chemical equations be balanced with matrices? For example, I have this equation:  
$$\mathrm{KMnO_4 + HCl = KCl + MnCl_2 + H_2O + Cl_2}$$
Then I get this:
$$a \cdot \mathrm{KMnO_4} + b \cdot \mathrm{HCl} = c \cdot \mathrm{KCl} + d \cdot \mathrm{MnCl_2} + e \cdot \mathrm{H_2O} + f \cdot \mathrm{Cl_2}$$
$$
\begin{align}
\mathrm{K}&: &a &= c \\
\mathrm{Mn}&: &a &= d \\
\mathrm{O}&: &4a &= e \\
\mathrm{H}&: &b &= 2e \\
\mathrm{Cl}&: &b &= c + 2d + 2f
\end{align}
$$
$$
\begin{bmatrix}
a&b&c&d&e&|&f\\
1&0&-1&0&0&|&0\\
1&0&0&-1&0&|&0\\
4&0&0&0&-1&|&0\\
0&1&0&0&-2&|&0\\
0&1&-1&-2&0&|&2
\end{bmatrix}
$$
How would I get the values of $a, b, c, d, e,$ and $f$ from here?
Side note: I'm following this.
 A: Here's a "mechanical" script that works for most chemical equations.
When $A_{ij} \ge 0$, product species in the solution vector will have negative coefficients, so there's no need to indicate them in the A-matrix.  
Or if you (correctly) assign all product species with negative coefficients in the A-matrix, then the solution vector will be positive, i.e. $x_k \ge 0$.  I'd rather let the script sort this out for me, but to each his own...

#!/usr/bin/env  julia
# Solve stoichiometry problem

function maxDen(r) # find largest denominator in a Rational array
  m = 1; for p in r;  m = max(den(p), m); end; return m
end

A = readdlm("stoich-A.mat")  # A = rows are elements, cols are species
P = pinv(A)*A; P = eye(P)-P  # P = projector into nullspace of A
x = rand(size(P[1,:])) * P   # x = solution  vector

x /= minimum(abs(x))*sign(x[1]) # convert x to integer coeffs
N = (2*3*5)^2 * 7 * 11 * 13     # highly composite number
r = (round(Int, N*x)) // N
r *= maxDen(r);  r *= maxDen(r);  r *= maxDen(r)
r = round(Int, r)
s = "\nThe stoichiometric coefficients are   $(r) \n"
@printf "%s" s

A: 
K: a = c Mn: a = d O: 4a = e H: b = 2e Cl: b = c + 2d + 2f
How would I get the values of a, b, c, d, e, and f from here?

Well... Reading the equations in the order they were given and using a as a parameter, one gets successively c = a, d = a, e = 4a, b = 2e = 8a, and 2f = b - c - 2d = 8a - a - 2a = 5a.
This is solved by a = c = d = 2, e = 8, b = 16 and f = 5, thus, the balanced equation is
$$\text{2 KMnO$^4$ + 16 HCl $\to$  2 KCl + 2 MnCl$^2$ + 8 H$^2$O + 5 Cl$^2$}$$
