First-principles characterization of the four phases of barium titanate