This paper presents the extension to both the trigonometric basis functions and the Legendre polynomials, of an alternative method which was presented previously and applied to m-degree polynomials as well as to exponential functions, to optimize the best fitting of numerical data. The proposed procedures are provided in a closed-form and therefore represent a good alternative solution tool to the QR decomposition, to tackle ill-conditioned best fitting problems.