A mathematical model of optimal control of fuel economy for parallel hybrid electric vehicles (HEVs) and its dynamic programming (DP) recursive equation and numerical DP algorithm are presented. The effect of frequent gear shifting and engine stop-starting on drivability and fuel economy are both taken into account in the cost function. To overcome the curse of dimensionality of numerical DP, an algorithm restricting the exploring region is proposed to reduce largely the computational complexity, and the quantization increments are carefully selected to balance computation accuracy and efficiency. Furthermore, instead of being simplified, the system model is converted into a real-time simulation code by using MATLAB/RTW to improve the computation efficiency. Finally, a case study is presented. The vehicle testing results, the simulation results, and the DP results are compared and analysed, indicating that the maximum performance and the optimal control policy of the HEV can be determined by the algorithm proposed in this paper within an acceptable time and that the results can be used to evaluate and improve the real-time control strategy.