Harmonics can be injected into the permanent magnet (PM) shape to maximize the output torque in five-phase machines. The optimal harmonics of different orders for maximum torque is mathematically derived and validated by the finite element (FE) method in this paper. The output torque of the five-phase machine with sinusoidal shape can be improved by 12.5% by injecting the optimal third harmonic. Meanwhile, 3.2% further more torque improvement can be obtained with the optimal third and fifth harmonics injected. However, the output torque barely change with the seventh harmonic injection. The torque ripple of the machines with shaped PMs is much lower than the machines with conventional tile PM. The electromagnetic performance for all the machines including back electromotive force, average torque, torque ripple, etc., are compared. Finally, the five-phase machine with third and fifth harmonics injection into the rotors is prototyped to verify the analytical and FE analyses.