Environmental variable functions are of key importance for gross primary productivity (GPP) modeling. This study proposes a method about the optimization of environmental variable function to obtain a more robust and accurate GPP quantitative model. The key idea is to explore the impact of environmental factors on the accuracy of the GPP quantitative model from the following three aspects: the first is using tensor as the alternative environmental factor equation to construct the basis-function set of photosynthetically active radiation (PAR), atmospheric temperature and atmospheric carbon dioxide concentration for the given environmental conditions, and soil moisture functions of new environmental conditions. The second is building 144 candidate model based on a tensor product. The third is finding the best model from the candidates according to the Shuffled Complex Evolution (SCE-UA) algorithm and the Minimum Loss Screening Method. Through the above experiments, we have the following conclusions: First, this paper obtains two new best models from 144 candidate models, and their accuracy is higher than that of the initial model, indicating that this paper proposes a more robust and accurate GPP quantitative model. Then, the model proposed in this paper has common characteristics, that is, PAR and atmospheric temperature can be replaced by more appropriate quantitative functions, named Sigmoid-like function and Q10 equation, and the carbon dioxide equation can use half-saturated equation or Sigmoid function. Finally, the method in this paper can provide new ideas for simulating the fluxes of other ecosystems, including soil carbon decomposition and plant respiration.