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), state of power (SOP) and so on. In this paper, an improved battery modeling method is proposed which is based on recursive least square 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 traditional recursive least square 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 objective function, a weight factor γ is added and the corresponding recursion formulae are also derived. 40 AH LiFePO4 batteries are chosen in the experiments for the validation of the method. The results of voltage outputs and errors generated from the proposed modeling method are compared under working profiles with those of traditional modeling method which show the improvement of model performance and effectiveness of the proposed modeling method.