To monitor and guarantee batteries of electric vehicles in normal operation, battery models should be established primarily for the further application in battery management system such as parameter identification and state estimation including state of charge (SOC), state of health (SOH) and so on. In this paper, an improved battery modeling method is proposed which is based on the recursive least square (RLS) algorithm employing an optimized objective function. The proposed modified objective function not only includes the normal sum of voltage error squares between measured voltage and model output voltage but also introduces a new variable representing the sum of first order difference error squares for both kinds of voltages. This specialty can undoubtedly guarantee better agreement for the measured output and the model output. The battery model used in this paper is selected to be the conventional second order equivalent circuit model. Similar to the conventional RLS algorithm, the detailed deduced procedure and recursion formulae of the algorithm which are applicable online are respectively provided based on the proposed objective function. Moreover, to further balance the weight of the two items in the optimized objective function, a weight factor w is added and the corresponding recursion formulae are also derived. 8 Ah LiFePO4 batteries are chosen in the experiments for the validation of the proposed algorithms. The results of voltage outputs and errors generated from the proposed modeling algorithms are compared under the Urban Dynamometer Driving Schedule (UDDS) profile and the New European Driving Cycle (NEDC) profile with those of traditional RLS algorithm which validate the improvement of model performance and effectiveness of the proposed algorithms.