Equation balancing and identification of phases