In mathematics, the term least squares refers to an approach for “solving” overdetermined linear or nonlinear systems of equations. A common problem in science is to fit a model to noisy measurements or observations. Instead of solving the equations exactly, which in many problems is not possible, we seek only to minimize the sum of the squares of the residuals.
The algebraic procedure of the method of least squares was first published by Legendre in 1805 [1]. It was justified as a statistical procedure by Gauss in 1809 [2], where he claimed to have discovered the method of least squares in 1795 [3]. Robert Adrian had already published a work in 1808, according to [4]. After Gauss, the method of least squares quickly became the standard procedure for analysis of astronomical and geodetic data. There are several good accounts of the history of the invention of least squares and the dispute between Gauss and Legendre, as shown in [3] and references therein. Gauss gave the method a theoretical basis in two memoirs [5], where he proves the optimality of the least squares estimate without any assumptions that the random variables follow a particular distribution. In an article by Yves [6] there is a survey of the history, development, and applications of least squares, including ordinary, constrained, weighted, and total least squares, where he includes information about fitting curves and surfaces from ancient civilizations, with applications to astronomy and geodesy.
The basic modern numerical methods for solving linear least squares problems were developed in the late 1960s. The decomposition by Householder transformations was developed by Golub and published in 1965 [7]. The implicit algorithm for computing the singular value decomposition (SVD) was developed by Kahan, Golub, and Wilkinson, and the final algorithm was published in 1970 [8]. Both fundamental matrix decompositions have since been developed and generalized to a high level of sophistication. Since then great progress has been made in methods for generalized and modified least squares problems in direct, and iterative methods for large sparse problems. Methods for total least squares problems, which allow errors also in the system matrix, have been systematically developed.
In this work we aim to give a simple overview of least squares for curve fitting. The idea is to illustrate, for a broad audience, the mathematical foundations and practical methods to solve this simple problem. Particularly, we will consider four methods: the normal equations method, the QR approach, the singular value decomposition (SVD), as well as a more recent approach based on neural networks. The last one has not been used as frequently as the classical ones, but it is very interesting because in modern days it has become a very important tool in many fields of modern knowledge, like data science (DS), machine learning (ML) and artificial intelligence (AI).
There are many problems in applications that can be addressed using the least squares approach. A common source of least squares problems is curve fitting. This is the one of the simplest least squares problems, but still it is a very fundamental problem, which contains all important ingredients of commonly ill posed problems and, even worse, they may be ill conditioned and difficult to compute with good precision using finite (inexact) arithmetic in modern computer devices. We start with the linear least squares problem.
Let’s assume that we have noisy experimental observations (points)
|
|
which relate two real quantities, as shown in figure 2. We want to fit a curve, represented by a real scalar function , to the given data. A linear model for the unknown curve can be represented as a linear combination of given (known) base functions , ,...,:
|
|
(1) |
where are unknown coefficients. A first naive approach to compute those coefficients is assuming that for each . This assumption yields the linear system , , which can be represented as , where
|
|
Depending on the problem or application, the base functions , , may be polynomials , exponentials , log-linear , among many others.
There are some drawbacks and difficulties with the previous approach: vector must belong to the column space of , denoted by , in order to get solution(s) of the linear system. The rank of is , and plays a important role. When , most likely , and the system has no solution; if , the undetermined linear system has infinite many solutions; finally, when , if the system has a solution, the computed curve produces undesirable oscillations, specially near the far right and left points, a well known phenomenon in approximation theory and numerical analysis, known as the Runge's phenomenon [9], demonstrating that high degree interpolation does not always produce better accuracy. The least squares approach considers the residuals, which are the differences between the observations and the model values:
|
|
Ordinary least squares to find the best fitting curve , consists in finding that minimizes the sum of squared residuals
|
|
The least squares criterion has important statistical interpretations, since the residual in
|
|
may be considered as a measurement error with a given probabilistic distribution. In fact, least squares produces what is known as the maximum-likelihood estimate of the parameter estimation of the given distribution. Even if the probabilistic assumptions are not satisfied, years of experience have shown that least squares produces useful results.
The quadratic function has gradient and Hessian given by and , respectively. Assuming that the design matrix has full rank, then the Hessian is positive definite, thus invertible, because is an symmetric matrix, and positive definite since when . Therefore, its minimum is the unique solution of the so called normal equations:
|
|
(2) |
and the best fitting curve, of the form (1), is obtained with the coefficients . The linear system (2) can be solved computationally using the Cholesky factorization or conjugate gradient iterations (for large scale problems).
Example 1: The best fitting polynomial of degree , say , to a set of data points is obtained solving the normal equations (2), where the design matrix is the Vandermonde matrix
|
|
A sufficient condition for to be full rank is that be all different, which may be proved using mathematical induction.
Remark 1: Rank deficient least squares problems, where the design matrix has linearly dependent columns, can be solved with specialized methods, like truncated singular value decomposition (SVD), regularization methods, decomposition with pivoting, and data filtering, among others. These difficulties are studied and understood more clearly when we start from basic principles. So, in order to keep the discussion easy we first consider the simplest case, where matrix is full rank, although it may be very ill-conditioned or near singular.
The least squares solution (2) satisfies
|
|
(3) |
where the square matrix defines an orthogonal projection, since
Therefore, the vector is the orthogonal projection of onto the column space of , as illustrated in Figure 1. Additionally, relation (3) defines a well posed problem (a consistent linear problem), with unique solution, since is full rank. This unique solution is the least squares solution obtained from the normal equations.
| Figure 1: is orthogonal to the minimum residual . |
The normal equations approach is a very simple procedure to solve the linear least squares problem. It is the most used approach in the scientific and engineering community, and very popular in statistical software. However, it must be used with precaution, specially when the design matrix is ill-conditioned (or it is rank deficient) and finite precision arithmetic, in digital conventional devices, is employed. In order to understand this phenomenon, it is convenient to show an example and then discuss the results.
Example 2: The National Institute of Standards and Technology (NIST) is a branch of the U.S. Department of Commerce responsible for establishing national and international standards. NIST maintains reference data sets for use in the calibration and certification of statistical software. On its website [10] we can find the Filip data set, which consists of 82 observations of a variable for different values. The aim is to model this data set using a 10th-degree polynomial. This is part of exercise 5.10 in Cleve Molers' book [11]. For this problem we have data points , and we want to compute coefficients for the 10th-degree polynomial. The design matrix has coefficients . In order to given an idea of the complexity of this matrix, we observe that its minimum coefficient is 1 and its maximum coefficient is a bit greater than , while its condition number is . The matrix of the normal equations, , is a much smaller matrix of size , but more singular, since its minimum and maximum coefficients (in absolute value) are close to 82 and , respectively, with a very high condition number . The matrix of the normal equations is highly ill-conditioned in this case because there are some clusters of data points very close to each other with almost identical values. The computed coefficients using the normal equations are shown in Table 1, along with the certified values provided by NIST. The NIST certified values were found solving the normal equations, but with multiple precision of 500 digits (which represents an idealization of what would be achieved if the calculations were made without rounding error). Our calculated values differ significantly from those of NIST, even in the sign, the relative difference is about 118. This dramatic difference is mainly because we are using finite arithmetic with 16-digit standard IEEE double precision, and solving the normal equations with the Cholesky factorization yields a relative error amplified proportionately to the product of the condition number times the machine epsilon. The computed residual keeps reasonable, though. Figure 2 shows Filip data along with the certified curve and our computed curve. The difference is most visible at the extremes, where our computed curve shows some pronounced oscillations.
| Polynomial coefficients | NIST | Normal equations |
| -1.467489614229800 | 3.397167285217155 | |
| -2.772179591933420 | 5.276500833542165 | |
| -2.316371081608930 | 3.545138197108058 | |
| -1.127973940983720 | 1.345510235823048 | |
| -0.354478233703349 | 0.316966659871258 | |
| -0.075124201739376 | 0.047864845714924 | |
| -0.010875318035534 | 0.004604461850533 | |
| -0.001062214985889 | 0.000269285797556 | |
| -0.000067019115459 | 0.000008526963608 | |
| -0.000002467810783 | 0.000000107514812 | |
| -0.000000040296253 | 0.000000000044407 | |
| Relative difference | 0 | 118 |
| Norm of residual | 0.028400823094900 | 0.041260859317660 |
| Figure 2:' Computed polynomial curve along with NISTs certified one. |
The previous numerical results for solving a least square problem have shown instability for the normal equations approach, when the design matrix is ill-conditioned. However the normal equations approach usually yields good results when the problem is of moderate size as well as well-conditioned. For the cases where the design matrix is ill-conditioned the QR factorization method is an excellent alternative. The SVD factorization is convenient when the design matrix is rank deficient, as will be discussed below.
We begin with the following theorem in reference [9].
Theorem 1: Each of full rank has a unique reduced factorization with . For simplicity we keep the discussion for the case . In this case is the same size than and is upper triangular. Actually this factorization is a matrix version of the Gram-Schmidt orthogonalization algorithm. More precisely, let be the linear independent column vectors of
|
|
then the orthonormal vectors , , ... , en obtained from the Gram-Schmidt orthogonalization gives the following matrix
|
|
which has the same column space that . These vectors are constructed sequentially, starting with , and they satisfy
|
|
Using the notation for and , we obtain
| = | ||
| = | ||
| = |
and
| = | ||
| = | ||
| = |
This set of equations leads to the so called reduced factorization:
| = | . |
This factorization allows another way to solve the overdetermined system , that arise in linear least square problems. The key property is that , where is the identity matrix of size . Then
|
|
(4) |
and this triangular system is solved easily using backward substitution. Furthermore, the obtained solution is the least squares solution, since the following set of relations are equivalent
|
|
where the projection matrices satisfy because the column space of is equal to the column space of .
A complete factorization of goes further by adding orthonormal columns to , and adding rows of zeros to , obtaining an orthogonal matrix and an upper triangular matrix as shown in Figure 3. In the complete factorization the additional columns , , are orthogonal to the column space of . Of course, the matrix is an orthogonal matrix, since , so .| Figure 3: The reduced and complete factorizations of |
Theorem 2: Any matrix () has a complete factorization , given by with an orthogonal matrix and an upper triangular matrix.
Warning. The Gram-Schmidt algorithm is numerically unstable (sensitive to rounding errors). Stabilization methods can be used by changing the order in which the operations are performed. Fortunately, there is an stable algorithm to compute the factorization which relies on Householder reflections.
| Figure 4: Householder reflection with vector . |
This reflection reflects on a hyperplane with normal unitary vector , and is given by
|
|
(5) |
where the outer (or external) product gives rise to a rank one symmetric matrix. We emphasize that, given the vector , the projection performs the following transformation
|
|
This matrix is a symmetric orthogonal matrix, i.e. it satisfies , .
Matrix is transformed into an upper triangular matrix by successively applying Householder matrix transformations
|
|
Each matrix is chosen to introduce zeros below the diagonal in the -th column. For example, for a matrix of , the operations are applied as shown below:
|
|
where each is of the form
|
|
which is a symmetric orthogonal matrix (see [12] for more details), is the identity matrix of size , and is the zero matrix of size . Actually, for any vector there are two Householder refletions, as shown in Figure 5, and each Householder matrix is constructed with the election . It is evident that this election allows to never be smaller than , avoiding cancellation by subtraction when dividing by to find in (5), thus ensuring stability of the method.
| Figure 5: Two Huoseholder reflections, constructed from . |
The above process is called Householder triangularization [13], and currently it is the most widely used method for finding the factorization. There are two procedures to construct the reflection matrices: Givens rotations and Householder reflections. Here we have described only Householder reflections. For further insight, we refer the reader to [14], [12] and [9].
We may compute the factorization , with . However, if we are interested only in the solution of the least squares problem, we do not have to compute explicitly either matrices or . We just find the factor and store it in the same memory space occupied by , and and store it in the same memory location occupied by . At the end, we solve the triangular system with backward substitution, as shown bellow.
Householder triangularization algorithm for solving with
** Triangularization **
** Backward sustitution **
Notation. We have used the MATLAB notation for arrays. For instance, represents the vector constructed with coefficients , and fixed; represents the submatrix with coefficients ; represents the subvector .
The most important steps in the previous algorithm are the last two lines in the ** Triangularization ** loop. The main idea is that it is not necessary to construct to compute a product , since
|
|
so we only need the vectors and at each step of the process. Numerical results are shown in Section 6.
The key idea to achieving the SVD of a matrix is symmetrizing. That is, if , we can consider the symmetric positive semidefinite matrices and . By the spectral theorem for symmetric matrices, these matrices are diagonalizable. For instance, if are the eigenvalues of with orthonormal eigenvectors , then
|
|
Each eigenvalue is real and non-negative, because
|
|
(6) |
Therefore, we can order the eigenvalues. Without loss of generality, we assume that
|
|
We remark that some eigenvalues may be repeated. Furthermore, each eigenvalue of is also an eigenvalue of since
|
|
We have found that matrices and have the same eigenvalues with corresponding eigenvectors
|
|
respectively. The eigenvectors of are orthonormal. However, the eigenvectors of are only orthogonal (), so we normalize them to get an orthonormal set in
|
|
(7) |
Definition 1: Non-negative values
|
|
are called the singular values of the matrix . Therefore, according to (7), the following relationship is obtained between the two sets of orthonormal vectors and :
|
|
(8) |
These relationships can be expressed as the matrix product:
|
|
which leads to
|
This factorization can also be expressed as sum of rank one matrices:
|
|
(10) |
Note. In the matrix equation or , the matrix is a rectangular matrix of size with orthonormal columns in , is an diagonal matrix with singular values, and is an orthogonal matrix (i.e. ). The reduced SVD is also valid for matrices with complex entries or coefficients, but now is Hermitian, so (the complex conjugate) replaces in the matrix factorization. For the interested reader, reference [15] is an extraordinary paper that surveys the contributions of five mathematicians who were responsible for establishing the existence of the SVD and developing its theory.
In most applications, the reduced SVD decomposition is employed. However, in textbooks and many publications, the `full' SVD decomposition is used. The reduced and full SVD are the same for . We illustrate two cases: and .
|
|
The previous results are summarized in the following theorem.
Theorem 3: Every matrix (, in the complex case) has a singular value decomposition of the form
|
|
(13) |
with the orthogonal matrices , (or unitary, in the complex case), and the matrix as indicated in the previous development.
As stated in [9] (Lecture 23), the SVD of , is related to the eigenvalue decomposition of the covariance matrix and mathematically it may be calculated doing the following:
But the problem with this strategy is that the algorithm is not stable, mainly because it relies on the covariance matrix , which we have found before in the normal equations for least squares problems. Additionally, the eigenvalue problem in general is very sensitive to numerical perturbations in computer’s finite precision arithmetic
An alternative stable way to compute the SVD is to reduce it to an eigenvalue problem by considering a Hermitian matrix and the corresponding eigenvalue system.
|
|
since implies and . Thus the singular values of are the absolute values of the eigenvalues of , and the singular vectors of can be extracted from the eigenvectors of , which can be done in an stable way, contrary to the previous strategy. This Hermitian eigenvalue problems are usually solved by a two-phase computation: first reduce the matrix to tridiagonal form, then diagonalize the tridiagonal matrix. The reduction is done by similarity unitary transformations, so the diagonal matrix contains the information about the singular values.
Actually, this strategy has been standard for computing the SVD since the work of Golub and Kahan in the 1960s [16]. The method involves in phase 1 applying Householder reflections alternately from the left and right of the matrix to reduce it to an upper bidiagonal form. In phase 2, the SVD of the bidiagonal matrix is determined with a variant of the QR algorithm. More recently, divide-and-conquer algorithms [17] have become the standard approach for computing the SVD of dense matrices in practice. These strategies overcome the computational difficulties associated with ill-conditioned or rank-deficient matrices during the SVD calculations.
Most of the software environments, like MATLAB and Phyton, incorporate very efficient algorithms and state of the art tools related to SVD. So, using those routines provide reasonable accurate results in most of the cases.
Concerning linear least squares problems, we know that this often leads to an inconsistent overdetermined system with , . Thus, we seek the minimum of the residual . We know that if is of full rank , then is positive definite symmetric and the least squares solution is given by
|
|
Via SVD, , and using that , , invertible, we have
|
|
and the least squares solution is given by
|
|
(14) |
What is remarkable is that the solution given by (14) is still valid, even if is rank deficient. The following formal definition of the pseudoinverse corroborate our claim.
Definition 2: Let a real matrix with rank , then its pseudoinverse is the matrix, denoted by , given by
|
|
(15) |
With this definition is well defined and it has the same size as . If is full rank, then is called the left inverse of since , and defines the projection onto the column space of . When is an invertible square matrix .
Fitting data to a polynomial curve. Given the point set . The algorithm for calculating , with the coefficients of the polynomial of degree , consists of the following steps:
In Section 5 we present numerical results and compare them with the results obtained with and normal equations algorithms.
As before we consider the Filip data set, which consists of 82 observations of a variable for different values. The aim is to model these data set using a 10th-degree polynomial, using both, the QR factorization and SVD, to solve the associated least squares problem. In Section 2 we gave a description of the data and showed numerical results with the normal equations approach. Here we use the QR algorithm with Householder reflections, introduced in Section 3, and the SVD, described in Section 4.
Table 2 shows the coefficient values of the polynomial obtained with both algorithms. The coefficients obtained with the QR algorithm are very close to the certified values of NIST (shown in Table 1), while the coefficients obtained with SVD are far from the certified ones, with two or three orders of magnitude apart and different signs for most of them. In fact, the relative difference of the coefficients obtained with the stable QR is insignificant, while the relative difference is as high as when the SVD is employed. However, the polynomial obtained with the SVD shows that the data still fit fairly well to the obtained curve, as shown in Figure 6. Again, the main differences between the accurate curve (red line) with respect to the less accurate (blue line) is more evident at the left and right extremes of the interval.
A better measure for accuracy is the norm of the residual , since the algorithms are designed to minimize this quantity. We observe that the residual obtained with the QR algorithm is very close to the certified one (shown in Figure 2) and, surprisingly this residual is slightly lower than the certified one, while the residual obtained with the SVD is higher than the certified one but lower than the one obtained with the normal equations. So, we conclude that the best method for this particular problem is QR, followed by SVD and the less accurate is obtained with the normal equations.
| Polynomial coefficients | QR | SVD |
| -1.467489624841714 | 8.443047022531269 | |
| -2.772179612867669 | 1.364997532790476 | |
| -2.316371099847143 | -5.350747822573923 | |
| -1.127973950228995 | -3.341901399544638 | |
| -0.354478236724762 | -0.406458058717373 | |
| -0.075124202404921 | 0.257727453320758 | |
| -0.010875318135669 | 0.119771677097139 | |
| -0.001062214996057 | 0.023140894524175 | |
| -0.000067019116127 | 0.002403995388431 | |
| -0.000002467810808 | 0.000131618846926 | |
| -0.000000040296253 | 0.000002990001355 | |
| Relative difference | 100 | |
| Norm of residual | 0.028210838088578 | 0.032726981836403 |
| Figure 6: Computed polynomial curve with QR and SVD. |
Finally, we present a neural network (NN) framework to address the same fitting problem analyzed in the preceding sections. While NNs have historically been less common than classical methods, they have recently emerged as powerful tools across numerous scientific disciplines. Our goal is to develop a NN that can be used together with the known data for curve fitting. If we have observations
|
|
(16) |
where , , are measurements of . The idea is to model as a NN of the form:
|
|
(17) |
where and are two sets of parameters of the neural network, which must be determined. This NN model consists of an input layer, hidden layers, each one containing neurons, and an additional output layer. The received input signal propagates through the network from the input layer to the output layer, through the hidden layers. When the signals arrive in each node, an activation function is used to produce the node output [18,19,20]. Neural networks with many layers (two or more) are called multi-layer neural networks.
Example 3: The model corresponding to a neural network with a single hidden layer consisting of five neurons, each activated by the hyperbolic tangent function, and a scalar output obtained through a linear combination of the hidden activations, can be expressed as
|
|
where . Explicitly, in this case, the neural network can be written as a functional representation of the input in the following form:
|
|
Hence, the complete model involves unknown parameters, which entirely determine the behavior of the neural network. The unknown parameters are optimized using an appropriate optimization algorithm (e.g., gradient descent) based on the given training dataset (16). The goal is to minimize a loss function that quantifies the discrepancy between the network's predictions and the true target values, which is described below.
Remark 2: It is known that any continuous, non-constant function mapping to can be approximated arbitrarily well by a multilayer neural network, see [21,22,23]. This result establishes the expressive power of feedforward neural networks. Specifically, it shows that even a network with a single hidden layer, containing a sufficient number of neurons and an appropriate activation function, can approximate any continuous function on compact subsets of .
In this work, the neural network is described in terms of the input , the output , and an input-to-output mapping . For any hidden layer , we consider the pre-activation and post-activation vectors as
|
|
(18) |
respectively. Thus, the activation in the -th hidden layer of the network for is given by [24]:
|
|
(19) |
where
|
|
(20) |
for . Here, and are the weights and bias parameters of layer . Activation functions must be chosen such that the differential operators can be readily and robustly evaluated using reverse mode automatic differentiation [25]. Throughout this work, we have been using relatively simple feedforward neural networks architectures with hyperbolic tangent and sigmoidal activation functions. Results show that these functions are robust for the proposed formulation. It is important to remark that as more layers and neurons are incorporated into the NN the number of parameters significantly increases. Thus the optimization process becomes less efficient.
Figure 7 shows an example of the computational graph representing a NN as described in equations (18)–(20). When one node's value is the input of another node, an arrow goes from one to another. In this particular example, we have
|
|
That is, the total number of hidden layers is . The first entry corresponds to the input layer () and contains a single neuron. The next four entries correspond to the hidden layers, each one with neurons. Finally, the last layer is the output layer and contains one neuron, corresponding to a single solution value. Bias is also considered (light grey nodes), there is a bias node in each layer, which has a value equal to the unit and is only connected to the nodes of the next layer. Although, the number of nodes for each layer can be different; the same number has been employed in this paper for simplicity.
| Figure 7: Neural network with 4 hidden layers, one input and one output. |
The parameters and in (17) are determined using a finite set of training points corresponding to the dataset in (16). Here, denotes the number of training points, which can be arbitrarily selected. The parameters are estimated by minimizing the mean squared error (MSE) loss
|
|
(21) |
where represents the error over the training dataset . The neural network defined in (18)–(20) is trained iteratively, updating the neuron weights by minimizing the discrepancy between the target values and the outputs .
Formally, the optimization problem can be written as
|
|
(22) |
where the vector collects all unknown weights and biases. Several optimization algorithms can be employed to solve the minimization problem (21) and (22), and the final performance strongly depends on the residual loss achieved by the chosen method. In this work, the optimization process is performed using gradient-based algorithms, such as Stochastic Gradient Descent (SGD) or Adam [26]. These methods iteratively adjust the network parameters in the direction that minimizes the loss function. Starting from an initial guess , the algorithm generates a sequence of iterates converging to a (local) minimizer as the stopping criterion is satisfied.
The required gradients are computed efficiently using automatic differentiation [27], which applies the chain rule to propagate derivatives through the computational graph. In practice, this process is known as backpropagation [28]. All computations were carried out in Python using Pytorch [26], a widely used and well-documented open-source library for machine learning.
To illustrate the capability of the NN, we consider the same curve-fitting problem based on the Filip dataset, which consists of 82 observations of a variable at different values of . The computed solution is shown in Figures 8 and 9. The predicted values of are obtained by training all the parameters of a five-layer neural network: the first layer contains a single neuron, while each hidden layer consists of twenty neurons. The hyperbolic tangent and sigmoidal activation functions are used throughout the network. It is worth noting that the NN solution closely resembles the one obtained using a 10th-degree polynomial fit (NIST). Therefore, this example shows its potential for generalization and robustness in more challenging scenarios.
| Figure 8: NN solution with the hyperbolic tangent as activation function. |
| Figure 9: NN solution with the sigmoidal as activation function. |
Fitting a curve to a given set of data is one of the most simple of the so called ill-posed problems. This is an example of a broad set of problems called least squares problems. This simple problem contains many of the ingredients, both theoretical and computational, of modern challenge and complex problems that are of great importance in computational modelling and applications, specially when computer solutions are obtained using finite precision machines. Commonly there is no `best computational algorithm' for general problems, but for a particular problem, like the one considered in this article, we can compare results obtained with different approaches or algorithms.
It is clear that the best fit to a 10th-degree polynomial is obtained with the QR algorithm, as it produces the smallest residual when compared to algorithms based on the normal equations and SVD. It is noteworthy that each method yields entirely different coefficients for this polynomial. Not only the sign of the coefficients but also the scale of the values differ drastically. These results demonstrate that even simple ill-posed problems must be studied and numerically solved with extreme care, employing stable state-of-the-art algorithms and tools that avoid the accumulation of rounding errors due to the finite arithmetic precision of computers.
Concerning the neural network approach, we obtained qualitatively excellent numerical results. The resulting fitted curve is smooth and provides an accurate representation of the data, and it appears to offer a slightly improved approximation when compared to the QR-based fit, while maintaining sufficient flexibility to capture the overall behavior. These results suggest that the multi-layer neural networks constitute an effective and robust framework for curve fitting. Is the NN approach better than the QR algorithm for curve fitting? Again, this general question depends of what you are looking for. But if you are able to construct with NN a 10th-degree polynomial that fits the given experimental data, then you are able to answer this particular question. A diligent reader may put their hands on the problem in order to give an answer.
Acknowledgements. We would like to express our sincere gratitude to the Department of Mathematics at Universidad Autónoma Metropolitana–Iztapalapa for their valuable support of this research work. The authors also gratefully acknowledge partial support from the Secretaría de Ciencia, Humanidades, Tecnología e Innovación (Secihti) through the Investigadores e Investigadoras por México program and the Ciencia de Frontera Project No. CF-2023-I-2639.
[1] A. M. Legendre. (1805) "Nouvelles methodes pour la determination des orbites des cometes". Courcier
[2] C. F. Gauss. (1963) "Theory of the Motion of the Heavenly Bodies Moving about the Sun in Conic Sections". Dover
[3] Åke Björck. (1996) "Numerical Methods for Least Squares Problems". SIAM
[4] Mansfield Merriman. (1877) "Note on the History of the Method of Least Squares", Volume 4. The Analyst 5 140–143
[5] C. F. Gauss. (1995) "Theory of the Combination of Observations Least Subject to Errors. Part I, Part II, Supplement". SIAM
[6] Yves Nievergelt. (2000) "A tutorial history of least squares with applications to astronomy and geodesy", Volume 121. Journal of Computational and Applied Mathematics 37–72
[7] P. Businger and G. H. Golub. (1965) "Linear least squares solutions by Householder transformations", Volume 7. Numerische Mathematik 269–276
[8] G. H. Golub and C. Reinsch. (1970) "Singular value decomposition and least squares solutions", Volume 14. Numerische Mathematik 403–420
[9] Lloyd N. Trefethen and David Bau III. (1997) "Numerical Linear Algebra". SIAM
[10] "Statistical Reference Datasets: Filip Data" https://www.itl.nist.gov/div898/strd/lls/data/Filip.shtml
[11] Cleve B. Moler. (2004) "Numerical Computing with MATLAB". SIAM
[12] L. Héctor Juárez. (2025) "Resultados relevantes del álgebra lineal en modelos y aplicaciones", Volume 16. Revista Metropolitana de Matemáticas Mixba'al 1
[13] A. S. Householder. (1958) "A Class of Methods for Inverting Matrices", Volume 6. Journal of the Society for Industrial and Applied Mathematics 2 189–195
[14] Gene H. Golub and Charles F. Van Loan. (1983) "Matrix Computations". The Johns Hopkins University Press
[15] G. W. Stewart. (1993) "On the Early History of the Singular Value Decomposition", Volume 35. SIAM Review 4 551–566
[16] G. H. Golub and W. Kahan. (1965) "Calculating the singular values and pseudo-inverse of a matrix", Volume 2. SIAM Journal on Numerical Analysis 2 205–224
[17] Y. Nakatsukasa and N. Higham. (2013) "Stable and efficient spectral divide and conquer algorithms for the symmetric eigenvalue decomposition and the SVD", Volume 35. SIAM Journal on Scientific Computing 3 A1325–A1349
[18] S. Marsland. (2015) "Machine Learning: An Algorithmic Perspective". CRC Press
[19] S. Pattanayak. (2017) "Pro Deep Learning with TensorFlow: A Mathematical Approach to Advanced Artificial Intelligence in Python". Apress
[20] G. Zaccone and R. Karim. (2018) "Deep Learning with TensorFlow: Explore Neural Networks and Build Intelligent Systems with Python". Packt Publishing Ltd
[21] G. Cybenko. (1989) "Approximation by superpositions of a sigmoidal function", Volume 2. Mathematics of Control, Signals and Systems 4 303–314
[22] K. Hornik and M. Stinchcombe and H. White. (1989) "Multilayer feedforward networks are universal approximators", Volume 2. Neural Networks 5 359–366
[23] A. Pinkus. (1999) "Approximation theory of the MLP model in neural networks", Volume 8. Acta Numerica 143–195
[24] C. Michoski and M. Milosavljevic and T. Oliver and D. Hatch. (2019) "Solving irregular and data-enriched differential equations using deep neural networks"
[25] D. A. Fournier and H. J. Skaug and J. Ancheta and J. Ianelli and A. Magnusson and M. N. Maunder and A. Nielsen and J. Sibert. (2012) "AD Model Builder: Using automatic differentiation for statistical inference of highly parameterized complex nonlinear models", Volume 27. Optimization Methods & Software 2 233–249
[26] . (2025) "PyTorch" https://pytorch.org
[27] A. G. Baydin and B. A. Pearlmutter and A. A. Radul and J. M. Siskind. (2015) "Automatic differentiation in machine learning: a survey"
[28] M. A. Nielsen. (2015) "Neural Networks and Deep Learning". Determination Press
Published on 27/12/25
Submitted on 20/11/25
Licence: CC BY-NC-SA license
Are you one of the authors of this document?