In accurate radiotherapy, energy spectra of high energy x-ray greatly affect the accuracy of dose calculation. Conventional discrete method failed to realize the stable solution, and the Schiff formula could not reflect the practical geometric shape of different linac system that showed the limitation to apply to other linacs. To obtain the photon energy spectra of linac in radiotherapy effectively, by use of monoenergetic percentage depth dose (PDD) simulated by Monte Carlo and measured PDD, an improved analytical model based on improvement of the Schiff formula was investigated, and several regression algorithms including Levenberg-Marquardt, Quasi-Newton, Gradient, Conjugate-Gradient, Newton, Principal-Axis and Nminimize algorithms were used to realize this model. The results were also compared with the conventional discrete method.A representative testing sample of Mohan6 (Monte Carlo simulated sample) and two representative samples of application (AAPM-55# report at an 18 MV's AECL Therac-20 medical linac, and our measurement at a 6 MV's BJ6-B medical linac) were used to test our method. The testing sample showed its accurate and stable results of the improved analytical method that the mean error could arrived at 0.2% to the reconstructed photon energy spectra, and the mean error of the reconstructed PDD could be at 0.003% in analytical method. By comparison with the discrete method, we found that even though the mean error in reconstructed PDD of the discrete method reduced to 0.002%, the discrete one with all above algorithms showed worse and unstable solution of photon energy spectra. And in clinical application samples, the analytical method also showed the same conclusion. So the conventional discrete method in reconstruction of energy spectra could be unreliable even though its reconstruction PDD agreed well to the original one. The improved analytical method also showed that it overcame the limitation of the Schiff formula that ignored various geometric shape of entire filtering system. So the improved analytical method to unfold photon energy spectra could be expected to be applied to various practical linac systems to obtain more accurate photon energy spectra.