Next Article in Journal
Randomized Average Kaczmarz Algorithm for Tensor Linear Systems
Next Article in Special Issue
Extending the Applicability of Highly Efficient Iterative Methods for Nonlinear Equations and Their Applications
Previous Article in Journal
Optimal Operation Policies in a Cross-Regional Fresh Product Supply Chain with Regional Government Subsidy Heterogeneity to Blockchain-Driven Traceability
Previous Article in Special Issue
On the Conditional Value at Risk Based on the Laplace Distribution with Application in GARCH Model
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

A Polynomial Fitting Problem: The Orthogonal Distances Method

by
Luis Alberto Cantera-Cantera
1,*,
Cristóbal Vargas-Jarillo
2,
Sergio Isaí Palomino-Reséndiz
1,
Yair Lozano-Hernández
3 and
Carlos Manuel Montelongo-Vázquez
1
1
Automation and Control Engineering Department, ESIME-IPN, Unidad Profesional Adolfo López Mateos, Zacatenco, Av. Luis Enrique Erro s/n, Mexico City C.P. 07738, Mexico
2
Automatic Control Department, CINVESTAV-IPN, Av. Instituto Politecnico Nacional 2508, Col. San Pedro Zacatenco, Mexico City C.P. 07360, Mexico
3
Unidad Profesional Interdisciplinaria de Ingeniería Campus Hidalgo, Instituto Politécnico Nacional, San Agustín Tlaxiaca C.P. 42162, Mexico
*
Author to whom correspondence should be addressed.
Mathematics 2022, 10(23), 4596; https://doi.org/10.3390/math10234596
Submission received: 25 October 2022 / Revised: 25 November 2022 / Accepted: 28 November 2022 / Published: 4 December 2022
(This article belongs to the Special Issue Numerical Analysis and Modeling)

Abstract

:
The classical curve-fitting problem to relate two variables, x and y, deals with polynomials. Generally, this problem is solved by the least squares method (LS), where the minimization function considers the vertical errors from the data points to the fitting curve. Another curve-fitting method is total least squares (TLS), which takes into account errors in both x and y variables. A further method is the orthogonal distances method (OD), which minimizes the sum of the squares of orthogonal distances from the data points to the fitting curve. In this work, we develop the OD method for the polynomial fitting of degree n and compare the TLS and OD methods. The results show that TLS and OD methods are not equivalent in general; however, both methods get the same estimates when a polynomial of degree 1 without an independent coefficient is considered. As examples, we consider the calibration curve-fitting problem of a R-type thermocouple by polynomials of degrees 1 to 4, with and without an independent coefficient, using the LS, TLS and OD methods.

1. Introduction

The curve-fitting or parameter estimation procedure consists of determining the parameters of a curve to obtain the best possible fit to observations. Depending on the curve, this problem can be classified as linear or nonlinear [1,2]. The most used curves for fitting in biology, physics, statistics and engineering are polynomials y = a 0 + a 1 x + + a n 1 x n 1 + a n x n [3,4,5,6,7]. The polynomial fitting is a linear problem and the most popular method used to solve it is least squares (LS) [8,9,10], which minimizes the sum of the squares of vertical errors from the data points ( x 1 , y 1 ) , , ( x m , y m ) to the polynomial curve. Another method that can be used to solve the problem is total least squares (TLS), which considers that both x and y are subject to errors; this method was developed mainly by Golub and Van Loan [11] and Van Huffel and Vandewalle [12]; however, the consideration that both variables x and y are subject to errors dates back at least to 1943 in the work of Deming [13]. Another way to solve the polynomial fitting is to consider the minimization of the sum of the squares of orthogonal distances from the data points to the polynomial curve, called in this article as the orthogonal distances (OD) method. Adcock [14] was the first to use the OD method for the straight line fitting; however, it has also been studied and used for the straight line and planes fitting in [15,16,17,18,19,20,21].
The remainder of this paper is structured as follows: Section 2 presents a brief description of the LS and TLS methods. The OD method is developed in Section 3 and it is also compared with the TLS method using the polynomial of degree 1. The approximation of the output voltage corresponding to different temperatures of a R-type thermocouple [22] using polynomials of degrees 1 to 4 by LS, TLS and OD methods is carried out in Section 4. Finally, a discussion and concluding remarks are presented in Section 5 and Section 6, respectively.
In general, this article studies the polynomial fitting problem by the OD method, and the main contributions are the following:
  • Development of the OD method for polynomial fitting of degree n.
  • Polynomial fitting of thermoelectric voltage data from a R-type thermocouple by OD, LS and TLS methods.
  • From the numerical experiments studied, the TLS and OD methods are not equivalent in general. However, both methods obtain the same estimates when the polynomial of degree 1 without an independent coefficient is used.

2. Polynomial Fitting by LS and TLS Methods

The polynomial fitting of degree n consists of determining the unknown parameters a 0 , a 1 , , a n of the polynomial defined for all real numbers x, such that f ( x ) = a 0 + a 1 x + + a n 1 x n 1 + a n x n . A brief description of the LS and TLS solutions for polynomial fitting are presented below.

2.1. The LS Method

The LS method is one of the most widely used minimization criteria for parameter estimation. The first publication of the method was made by A. M. Legendre in 1805; however, C. F. Gauss claimed that he used the method 10 years earlier [16]. The classical LS method seeks to determine the curve y = f ( x ) , which best fits to observations ( x i , y i ) with i = 1 , , m , minimizing the sum of the squares of vertical errors defined as r i = y i f ( x i ) ; however, there are some variants of the method, such as weighted least squares, generalized least squares and maximum likelihood, among others, and it can be applied to different mathematical models, such as algebraic models, and continuous and discrete dynamic models [23,24,25,26,27,28] using the off-line and recursive schemes [20,29,30].
Since the article considers the classical LS method under the off-line scheme, the vector of vertical errors for the polynomial of degree n and observations ( x i , y i ) is given by
r = r 1 r 2 r m = y 1 y 2 y m 1 x 1 x 1 n 1 x 2 x 2 n 1 x m x m n a 0 a 1 a n .
Defining
y : = y 1 y 2 y m , A : = 1 x 1 x 1 n 1 x 2 x 2 n 1 x m x m n , p : = a 0 a 1 a n ,
we obtain
r = y Ap ,
where A R m × ( n + 1 ) , y R m and p R ( n + 1 ) .
Taking the squared 2-norm of vector (1), we obtain
r 2 2 = y Ap 2 2 = i = 1 m r i 2 .
The LS solution is the vector p such that it minimizes the functional (2). Since it is a linear minimization problem, the LS solution can be found by elementary calculus [10,31,32]. The p LS solution which minimizes (2) is unique if matrix A has independent columns, which means that it has rank ρ ( A ) = n + 1 . Therefore, the p LS solution satisfies the normal equations A Ap = A y and is defined by p = ( A A ) 1 A y .
On the other hand, if matrix A has dependent columns or is not invertible, the p LS solution which minimizes (2) is defined by
p = A y ,
where A is called the Moore–Penrose pseudoinverse of A , and it is defined by
A = V Σ q 1 0 0 0 U .
Equation (3) is called the pseudoinverse solution of the LS method, and the Moore–Penrose pseudoinverse is defined by the matrices of the singular value decomposition (SVD) given by the following theorem. Throughout the text, the rank of any matrix will be denoted by ρ ( · ) .
Theorem 1.
([10]). Let any matrix A R m × ( n + 1 ) . The SVD of A is
A = U Σ q 0 0 0 V ,
where U R m × m and V R ( n + 1 ) × ( n + 1 ) are unitary matrices and Σ q = diag ( σ 1 , σ 2 , , σ q ) . The numbers σ 1 σ 2 σ q > 0 are called the singular values of A and ρ ( A ) = q .
More properties of the Moore–Penrose pseudoinverse can be found in [10,32].

2.2. The TLS Method

This section presents the most important results of the TLS method from [12] for polynomial fitting.
Rewriting the system of linear algebraic equations Ap = y as follows
A y p 1 = 0 ,
since A R m × ( n + 1 ) , y R m and p R ( n + 1 ) , it can be defined Λ : = A y R m × ( n + 2 ) and z : = p 1 R ( n + 2 ) to obtain
Λ z = 0 .
Since Equation (4) represents a homogeneous system of linear algebraic equations, the z solution is in the null space of Λ , which means that the parameters vector p is also in the null space of Λ . If matrix Λ in (4) has rank ρ ( Λ ) = n + 2 , the SVD of Λ is given by
Λ = U Σ V = i = 1 n + 2 σ i u i v i ,
where the singular values σ i and singular vectors u i and v i satisfy
Λ v 1 = σ 1 u 1 , Λ v 2 = σ 2 u 2 , Λ v n + 1 = σ n + 1 u n + 1 , Λ v n + 2 = σ n + 2 u n + 2 .
From (5), it can be see that system (4) does not have a vector v in the null space of Λ , and therefore the TLS method searches for a matrix Λ k with ρ ( Λ k ) = k < n + 2 , such that Λ Λ k is minimal. Once a minimizing Λ k is found, any z vector satisfying Λ k z = 0 is called the TLS solution and Δ Λ = Λ Λ k is the TLS correction.
The minimization is found by the Eckart–Young–Mirsky theorem. This theorem was initially proved by Eckart and Young [33] using the Frobenius norm, and later Mirsky [34] proved it using the 2-norm. In this work, it is used with the 2-norm. The Eckart–Young–Mirsky theorem using the 2-norm is presented below.
Theorem 2.
([12]). Let the SVD of Λ R m × ( n + 2 ) be given by Λ = U Σ V with ρ ( Λ ) = q and let k < q ; then, the matrix
Λ k = i = 1 k σ i u i v i ,
satisfies
min ρ ( Λ ) = k Λ B 2 = Λ Λ k 2 = σ k + 1 .
Applying the Eckart–Young–Mirsky Theorem 2 to (4), the best matrix approximation Λ k to the matrix Λ is given by
Λ k = i = 1 n + 1 σ i u i v i , σ 1 σ n + 1 > 0 .
Notice that Λ k has rank ρ ( Λ k ) = n + 1 , then the singular values σ i and singular vectors u i , v i now satisfy
Λ k v 1 = σ 1 u 1 , Λ k v 2 = σ 2 u 2 , Λ k v n + 1 = σ n + 1 u n + 1 , Λ k v n + 2 = 0 .
From Equation (6), the vector v n + 2 is in the null space of Λ k , and therefore, a z TLS solution satisfying Λ k z = 0 is given by
z = p 1 = v n + 2 = v 1 , n + 2 v 2 , n + 2 v n + 2 , n + 2 .
The TLS solution will be scaled to obtain 1 in the last row of (7):
z = p 1 = 1 v n + 2 , n + 2 v 1 , n + 2 v 2 , n + 2 v n + 2 , n + 2 ,
then, if v n + 2 , n + 2 0 , the parameters vector p is given by
p = 1 v n + 2 , n + 2 v 1 , n + 2 v 2 , n + 2 v n + 1 , n + 2 .
An alternative form to obtain (8) is as follows. Since the z solution is also an eigenvector of Λ Λ , it is associated with the eigenvalue σ n + 2 2 . Hence the eigenvalue–eigenvector equation is given by
Λ Λ p 1 = σ n + 2 2 p 1 ,
substituting Λ : = A y we obtain
A A A y y A y y p 1 = σ n + 2 2 p 1 .
Selecting the first row of Equation (9)
A A p A y = σ n + 2 2 p ,
and solving for the parameters vector p , we obtain
p = ( A A σ n + 2 2 I ) 1 A y .
The following theorem establishes the uniqueness and existence conditions of the TLS solution.
Theorem 3.
([12]). Let the singular values of A be σ ^ 1 σ ^ 2 σ ^ n + 1 > 0 , and the singular values of A y be σ 1 σ 2 σ n + 2 > 0 . If σ ^ n + 1 > σ n + 2 then the TLS problem has a unique solution.
As we can see, one problem of the TLS solution is the loss of uniqueness due to repeated singular values, and another is the indeterminate form in (8) if v n + 2 , n + 2 = 0 ; those problems are called nongeneric TLS problems, and more details of them can be found in [35,36,37].

3. Polynomial Fitting by OD Method

The OD method minimizes the sum of the squares of the orthogonal distances from observations ( x 1 , y 1 ) , , ( x m , y m ) to the polynomial curve y = f ( x ) . Considering Figure 1, where a 1 is the vector of the observation ( x 1 , y 1 ) , c is a vector on the curve x , f ( x ) , c : = d d x c = 1 , f ( x ) is the tangent vector at c and the vector d 1 is defined by
d 1 = a 1 c .
The vector d 1 in Figure 1 is orthogonal to the curve f ( x ) at c if the dot product between vectors d 1 and c satisfies
d 1 · c = 0 .
Substituting c and d 1 in (12), we obtain
d 1 · c = x 1 x + f ( x ) y 1 f ( x ) = 0 .
Equation (13) is called the orthogonality condition, and its solution determines the point x 1 * , f ( x 1 * ) on the curve f ( x ) where the vectors d 1 and c are orthogonal. This point also determines the orthogonal distance vector d 1 . The 2-norm of vector d 1 is the orthogonal distance from the observation ( x 1 , y 1 ) to the curve f ( x ) denoted by d 1 2 .
If the polynomial curve considered is f 1 ( x ) = a 0 + a 1 x , then by the orthogonality condition (13) and the squared 2-norm of vector d i (11), the squares of the orthogonal distances for the observations ( x i , y i ) with i = 1 , , m are given by
d i 2 2 = r i 2 1 + a 1 2 ,
with r i = y i ( a 0 + a 1 x i ) . Defining the distances vector d = d 1 2 d 2 2 d m 2 and taking the squared 2-norm of d , we obtain
d 2 2 = d · d = 1 1 + a 1 2 i = 1 m r i 2 .
Equation (14) is the functional of the sum of the squares of the orthogonal distances from observations ( x i , y i ) to the polynomial curve y = a 0 + a 1 x . The parameters a 0 , a 1 that minimize the functional (14) are defined below.
Considering the function
f ( a 0 , a 1 ) : = 1 1 + a 1 2 i = 1 m r i 2 ,
with r i = y i ( a 0 + a 1 x i ) . Differentiating (15) with respect to a 1 and a 0 and equating to zero
f a 1 : = f a 1 = i = 1 m x i y i + a 1 i = 1 m ( x i 2 y i 2 ) + a 0 i = 1 m x i + a 1 2 i = 1 m x i y i a 1 2 a 0 i = 1 m x i + 2 a 1 a 0 i = 1 m y i m a 1 a 0 2 = 0 .
f a 0 : = f a 0 = i = 1 m y i a 1 i = 1 m x i m a 0 = 0 .
From Equation (17) we obtain
a 0 = 1 m i = 1 m y i a 1 i = 1 m x i .
Substituting (18) into (16) boils down tobecomes
μ 1 a 1 2 + μ 2 a 1 + μ 3 = 0 ,
where
μ 1 = i = 1 m x i y i 1 m i = 1 m y i i = 1 m x i , μ 2 = i = 1 m ( x i 2 y i 2 ) + 1 m i = 1 m y i 2 1 m i = 1 m x i 2 , μ 3 = 1 m i = 1 m y i i = 1 m x i i = 1 m x i y i .
Solving quadratic Equation (19)
a 1 ( 1 , 2 ) = μ 2 ± μ 2 2 4 μ 1 μ 3 2 μ 1
and substituting (20) into (18), we obtain
a 0 ( 1 , 2 ) = 1 m i = 1 m y i a 1 ( 1 , 2 ) i = 1 m x i .
Since the sets of values ( a 1 ( 1 ) , a 0 ( 1 ) ) and ( a 1 ( 2 ) , a 0 ( 2 ) ) are the critical points of function (15), the second derivative test is used to determine the minimum.
Definition 1.
Let f ( a 0 , a 1 ) be a differentiable function with respect to a 0 and a 1 . Let H f ( a 0 * , a 1 * ) = f a 1 a 1 ( a 0 * , a 1 * ) f a 0 a 0 ( a 0 * , a 1 * ) [ f a 0 a 1 ( a 0 * , a 1 * ) ] 2 . If ( a * , b * ) is a critical point of f, that is, f a 0 ( a 0 * , a 1 * ) = 0 and f a 1 ( a 0 * , a 1 * ) = 0 . Then
  • If H f ( a 0 * , a 1 * ) > 0 and f a 1 a 1 ( a * , b * ) > 0 , then f ( a 0 * , a 1 * ) is a local minimum value of f.
  • If H f ( a 0 * , a 1 * ) > 0 and f a 1 a 1 ( a * , b * ) < 0 , then f ( a 0 * , a 1 * ) is a local maximum value of f.
The second derivatives of function (15) with respect to a 0 and a 1 are given by
f a 0 a 0 : = 2 f a 0 2 = 2 m 1 + a 1 2 , f a 1 a 1 : = 2 f a 1 2 = 1 ( 1 + a 1 2 ) 3 ( ( 6 a 1 2 2 ) i = 1 m ( y i a 1 x i a 0 ) 2 4 ( a 1 + a 1 3 ) { 2 i = 1 m x i y i + 2 a 1 i = 1 m x i 2
+ 2 a 0 i = 1 m x i } + 2 ( 1 + a 1 2 ) 2 i = 1 m x i 2 ) ,
f a 1 a 0 : = 2 f a 1 a 0 = f a 0 a 1 : = 2 f a 0 a 1 = 2 ( 1 + a 1 2 ) 2 ( i = 1 m x i + 2 a 1 i = 1 m y i a 1 2 i = 1 m x i 2 m a 1 a 0 ) .
Using the second derivative test Definition 1, the parameters a 0 and a 1 that minimize (15) are determined by (20) and (21).
On the other hand, if we consider now a polynomial of degree 2, f 2 ( x ) = a 0 + a 1 x + a 2 x 2 . Then, substituting f 2 ( x ) and f 2 ( x ) into the orthogonality condition (13) we obtain the cubic equation
x 3 + μ ^ 1 x 2 + μ ^ 2 x + μ ^ 3 = 0 ,
with
μ ^ 1 = 3 a 1 2 a 2 , μ ^ 2 = 1 + a 1 2 + 2 a 0 a 2 2 a 2 y i 2 a 2 2 , μ ^ 3 = a 1 a 0 x i a 1 y i 2 a 2 2 .
The real solution of Equation (25) determines the points x i * , f 2 ( x i * ) on the curve f 2 ( x ) , where the orthogonal distances for each observation d i 2 are determined. Then, solving (25) by Cardano’s formulas [38], the real solution for each observation is determined by the formula
x i * = ν + ν 2 + 4 ω 3 27 2 3 + ν ν 2 + 4 ω 3 27 2 3 μ ^ 1 3 ,
where
ν = μ ^ 3 + 2 27 μ ^ 1 3 μ ^ 1 μ ^ 2 3 , ω = μ ^ 2 1 3 μ ^ 1 2 .
Hence, the squared 2-norm of vector d i (11) is defined by
d i 2 2 = ( x i x i * ) 2 + ( y i f 2 ( x i * ) ) 2 .
Taking the squared 2-norm of the distances vector d = d 1 2 d 2 2 d m 2 , the functional of the sum of the squares of the orthogonal distances for the polynomial of degree 2 is defined by
d 2 2 = d · d = i = 1 m ( x i x i * ) 2 + ( y i f 2 ( x i * ) ) 2 .
Notice that the polynomial fitting of degree 2 by OD method is a nonlinear minimization problem.
Considering now a cubic polynomial curve, f 3 ( x ) = a 0 + a 1 x + a 2 x 2 + a 3 x 3 , then by the orthogonality condition (13), a fifth degree equation is obtained:
x 5 + μ ¯ 1 x 4 + μ ¯ 2 x 3 + μ ¯ 3 x 2 + μ ¯ 4 x + μ ¯ 5 = 0 ,
with
μ ¯ 1 = 5 a 2 3 a 3 , μ ¯ 2 = 4 a 1 a 3 + 2 a 2 2 3 a 3 2 , μ ¯ 3 = a 1 a 2 + a 0 a 3 a 3 y i a 3 2 , μ ¯ 4 = 1 + a 1 2 + 2 a 0 a 2 2 a 2 y i 3 a 3 2 , μ ¯ 5 = a 0 a 1 a 1 y i x i 3 a 3 2 .
Equation (28) in general cannot be solved analytically; the roots must be obtained with a numerical method [31,39,40]. Once Equation (28) is solved for each observation, the points x i * , f 3 ( x i * ) on the curve determine the orthogonal distance vectors d i 2 , then the squared 2-norm of the distances vector d = d 1 2 d 2 2 d m 2 determines the functional to be minimized:
d 2 2 = d · d = i = 1 m ( x i x i * ) 2 + ( y i f 3 ( x i * ) ) 2 .
The general case is when a polynomial curve of degree n is considered, f n ( x ) = a 0 + a 1 x + + a n x n . From the orthogonality condition (13), an equation of degree 2 n 1 is obtained. Since it is of an odd degree, it has at least one real root. Hence the functional of the sum of the squares of orthogonal distances to be minimized is given by
d 2 2 = d · d = i = 1 m ( x i x i * ) 2 + ( y i f n ( x i * ) ) 2 .
As we can see, there are two numerical problems when the polynomial fitting problem of degree n is solved by the OD method. Firstly, a real-root-finding problem of an equation of degree 2 n 1 given by the orthogonality condition (13) and then a nonlinear minimization problem of the sum of the squares of the orthogonal distances is given by (30). In this sense, the real-root-finding problem can be solved by the fzero routine from MATLAB, whereas the fminsearch routine also from MATLAB [41] can be used to solve the nonlinear minimization problem. It is worth mentioning that the polynomial fitting problem of degree 1 can be solved by the analytic formulas (20) and (21), and the second derivative test Definition 1.

Contrasting the OD and TLS Methods

In previous sections, the LS, TLS and OD methods for the polynomial fitting were presented. However, Golub and Van Loan [11] and Van Huffel and Vandewalle [12] mentioned that the TLS method also minimizes the orthogonal distances. In order to review this statement, this section analyzes the parameter estimation by the TLS and OD methods for the most simple polynomial, the straight line f 1 ( x ) = a 0 + a 1 x .
Applying the OD method, the functional of the sum of the squares of the orthogonal distances for the straight line fitting to be minimized is given by
d 2 2 = 1 1 + a 1 2 i = 1 m r i 2 ,
with r i = y i ( a 0 + a 1 x i ) .
On the other hand, the z TLS solution for the straight line satisfies the eigenvalue–eigenvector equation
Λ Λ z = σ 2 2 z ,
where Λ : = A y and z : = p 1 . Premultiplying Equation (32) by z and solving for σ 2 2 , we obtain
σ 2 2 = Λ z 2 2 z 2 2 ,
and substituting Λ and z results init gets
σ 2 2 = Ap y 2 2 p 2 2 + 1 .
Notice that the numerator of Equation (33) is the same as in Equation (2), then, substituting (2) in (33) reduces to
σ 2 2 = 1 p 2 2 + 1 i = 1 m r i 2 ,
where p is the parameters vector. Since the parameters vector for the straight line is p = a 0 a 1 , Equation (34) reduces to
σ 2 2 = 1 a 0 2 + a 1 2 + 1 i = 1 m r i 2 .
Notice that Equations (35) and (31) are not equal, since
1 1 + a 1 2 i = 1 m r i 2 1 a 0 2 + a 1 2 + 1 i = 1 m r i 2 ,
then TLS method does not minimize the orthogonal distances. However, if we consider the straight line without independent coefficient f 1 ( x ) = a 1 x , Equations (35) and (31) are equal and both methods minimize the orthogonal distances. Hence the OD and TLS methods are not equivalent in general.
The next section presents the parameter estimation of polynomial functions of degree 1 to 4 with and without an independent coefficient by the LS, TLS and OD methods.

4. Polynomial Fitting of Thermoelectric Voltage by LS, TLS and OD Methods

Considering the observations of temperature and thermoelectric voltage ( T i , E i ) from a R-type thermocouple for the temperature range −50 C to 1064 C with increment of 1 C obtained from [22], this section shows the calibration curve fitting of the R-type thermocouple by polynomials of degree 1 to 4 by LS, TLS and OD methods.
In order to evaluate the predictive performance of the calibration polynomials, the criteria of the extreme values of errors, the average of the absolute errors, the standard deviation and the coefficient of determination R 2 were used [3,4,6].
The error of calibration polynomial is defined as
e i = E i E ^ i ,
where E i is thermoelectric voltage data and E ^ i is the predicted value of the thermoelectric voltage with the calibration polynomial. The average of the absolute errors is given by
e a v e = 1 m i = 1 m | e i | ,
where | e i | is the absolute value of e i and m is the number of data. The standard deviation of the calibration polynomial is defined by
e s t d = 1 m 1 i = 1 m e i 2 .
The coefficient of determination R 2 is given by
R 2 = 1 i = 1 m ( E i E ^ i ) 2 i = 1 m ( E i E ¯ ) 2 ,
where E ¯ is the average of the thermoelectric voltage data.
The calibration polynomial fitting with an independent coefficient is presented below.

4.1. Calibration Polynomial Fitting with Independent Coefficient

The polynomial fitting of functions (40) by LS and TLS methods was solved by Equations (3) and (10), respectively.
E ( T ) = a 0 + j = 1 n a j T j .
On the other hand, the polynomial fitting of degree n = 1 by the OD method was carried out applying Algorithm 1, which uses the analytic formulas (20) and (21), and the second derivative test Definition 1. The nonlinear minimization of function (27) for the polynomial fitting of degree n = 2 was solved applying the Algorithm 2 which uses the fminsearch routine from MATLAB. Finally, the polynomial fitting of functions of degree n = 3 and n = 4 was solved applying the Algorithm 3 which uses the fzero and fminsearch routines.
Algorithm 1 Polynomial fitting of degree 1 by OD method.
Input Data ( x i , y i ) .
Output Parameters a 0 , a 1 .
Step 1. Compute
a 1 ( 1 , 2 ) = μ 2 ± μ 2 2 4 μ 1 μ 3 2 μ 1 , a 0 ( 1 , 2 ) = 1 m i = 1 m y i a 1 ( 1 , 2 ) i = 1 m x i .
Step 2. Compute H f ( a 0 * , a 1 * ) and f a 1 a 1 ( a 0 * , a 1 * ) .
Step 3. If H f ( a 0 * , a 1 * ) > 0 and f a 1 a 1 ( a 0 * , a 1 * ) > 0 then ( a 0 * , a 1 * ) is a local minimum.
Step 4. Output ( a 0 * , a 1 * ) .
Algorithm 2 Polynomial fitting of degree 2 by OD method.
Input Data ( x i , y i ) ; initial approximation of the parameters P 0 = ( a 0 , a 1 , a 2 ) ; optimization options: TolFun, TolX, MaxIter, MaxFunEvals.
Output Parameters P = ( a 0 , a 1 , a 2 ) .
function fun ( P , x i , y i )
x i * = ν + ν 2 + 4 ω 3 27 2 3 + ν ν 2 + 4 ω 3 27 2 3 μ ^ 1 3 ; i = 1 m ( x i x i * ) 2 + ( y i f 2 ( x i * ) ) 2 ;
end function
Step 1. Call fminsearch ( fun , P 0 , options ) .
Step 2. Output P = ( a 0 , a 1 , a 2 ) .
Algorithm 3 Polynomial fitting of degree n > 2 by OD method.
Input Data ( x i , y i ) ; initial approximation of the orthogonality condition solution x 0 * ; initial approximation of the parameters P 0 ; optimization options: TolFun, TolX, MaxIter, MaxFunEvals.
Output Parameters P.
function funZ ( P , x i , y i , x 0 * )
x i x + f n ( x ) y i f n ( x ) ;
end function
function fun ( P , x i , y i , x 0 * )
x i * = fzero ( funZ , x 0 * , options ) ; i = 1 m ( x i x i * ) 2 + ( y i f n ( x i * ) ) 2 ;
end function
Step 1. Call fminsearch ( fun , P 0 , options ) .
Step 2. Output P.
Using Algorithms 1–3 and long output display format, the calibration polynomials of degree 1 to 4 by the LS, TLS and OD methods are presented in Table 1, Table 2, Table 3 and Table 4, respectively. The performance of the calibration polynomials is presented in Table 5.
Since each set of parameters in Table 1, Table 2, Table 3 and Table 4 is distinct, different calibration polynomials were obtained with all methods used. It is important to mention that if we had used a shorter output display format, some parameters estimated would have been the same.
The polynomial fitting without the independent coefficient a 0 is presented below.

4.2. Calibration Polynomial Fitting without Independent Coefficient

The calibration polynomials for the R-type thermocouple without independent coefficient a 0 are defined by
E ( T ) = j = 1 n a j T j .
Using the observations of temperature and thermoelectric voltage for the temperature range − 50 C to 1064 C, the calibration polynomial fitting of degrees 1 to 4 without an independent coefficient by the LS, TLS and OD methods are presented in Table 6, Table 7, Table 8 and Table 9, respectively. The performance of the calibration polynomials is shown in Table 10.
From Table 6, regardless of the output display format type, the estimates for a 1 by the TLS and OD methods were the same. On the other hand, since each set of parameters in Table 7, Table 8 and Table 9 is distinct, the TLS method also minimizes the orthogonal distances when a polynomial of degree 1 without an independent coefficient is considered.

5. Discussion

The article presents the OD method for the polynomial fitting problem for which the minimization criteria are the sum of the squares of the orthogonal distances from data points to the polynomial curve; hence, the functional obtained is nonlinear, just like the minimization problem. Applying the OD method to fit calibration polynomials of a R-type thermocouple, different polynomials were obtained compared with the LS and TLS methods. However, if we consider the calibration polynomial of degree 1 without an independent coefficient, the OD and TLS methods obtain the same estimates. An important aspect to consider is the output display format of computations, because if a short output format is used, some results with the OD and TLS methods would be the same. On the other hand, from a practical point of view, the polynomial fitting by the OD method requires computations of roots of equations of degree 2 n 1 and a nonlinear minimization, so the method can be implemented with different minimization and root finding algorithms.

6. Conclusions

This work presented two classical methods for solving the polynomial fitting problem, the least squares (LS) and total least squares (TLS) methods. Then, using elementary vector geometry, the orthogonal distances (OD) method for solving the polynomial fitting problem of degree n was developed. All methods used in this work have advantages and disadvantages. The LS and TLS solutions are easier to obtain than the OD method, as they are obtained by Equations (3) and (10), respectively. The OD solution for the polynomial fitting of degree n > 1 needs to solve two numerical problems. Firstly a real-root finding routine is applied to an equation of degree 2n − 1 resulting from the orthogonality condition (13); since it is of an odd degree, it has at least one real root. Then a nonlinear minimization routine is applied to the functional of the sum of the squares of the orthogonal distances (30). The polynomial fitting problem of degree 1 by OD method is solved applying the analytic Formulas (20), (21) and the second derivative test Definition 1. On the other hand, the LS and TLS methods are ill-conditioned problems [10,12,39] which cause deficient estimates; furthermore, the TLS method has nongeneric problems [35,36,37]. Since the OD method considers a different minimization criterion than the LS and TLS methods, it represents a different alternative for polynomial fitting. Furthermore, the numerical experiments demonstrated that TLS and OD methods are not equivalent in general, and that the performance criteria of the LS and OD methods are similar. However, from the cases studied, TLS and OD methods obtain the same estimates when the polynomial of degree 1 without an independent coefficient is considered, and therefore, the performance criteria are also equal. It is important to highlight that when the independent coefficient is not considered, the performance criteria are similar to the three methods used. On the other hand, since the minimization of the functional of the OD method is nonlinear and numerical computations of roots are also needed, the implementation of the OD method needs a large computing capacity and efficient algorithms.
Finally, future works include applying the calibration curves obtained in practical applications and solving polynomial fitting problems from different disciplines with the OD method, using different minimization and root-finding algorithms.

Author Contributions

Conceptualization, C.V.-J.; methodology, C.V.-J.; software, L.A.C.-C.; validation, L.A.C.-C. and Y.L.-H.; formal analysis, L.A.C.-C.; investigation, S.I.P.-R. and C.M.M.-V.; data curation, Y.L.-H.; writing—original draft preparation, L.A.C.-C.; writing—review and editing, L.A.C.-C., S.I.P.-R. and C.M.M.-V.; visualization, S.I.P.-R., Y.L.-H. and C.M.M.-V.; supervision, C.V.-J.; project administration, L.A.C.-C.; funding acquisition, C.V.-J., L.A.C.-C., S.I.P.-R., Y.L.-H. and C.M.M.-V. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by Secretaría de Investigación y Posgrado SIP IPN under grants 20221223, 20227019, 20221135 and 20220039.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Not applicable.

Acknowledgments

We are greatly indebted to the anonymous referees for their useful suggestions.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Bard, Y. Nonlinear Parameter Estimation; Academic Press: New York, NY, USA, 1974. [Google Scholar]
  2. Lancaster, P.; Salkauskas, K. Curve and Surface Fitting: An Introduction; Academic Press: London, UK, 1986. [Google Scholar]
  3. Chen, A.; Chen, C. Evaluation of piecewise polynomial equations for two types of thermocouples. Sensors 2013, 13, 17084–17097. [Google Scholar] [CrossRef] [PubMed] [Green Version]
  4. Chen, C.; Weng, Y.K.; Shen, T.C. Performance evaluation of an infrared thermocouple. Sensors 2010, 10, 10081–10094. [Google Scholar] [CrossRef] [PubMed]
  5. Izonin, I.; Tkachenko, R.; Kryvinska, N.; Tkachenko, P. Multiple linear regression based on coefficients identification using non-iterative SGTM neural-like structure. In International Work-Conference on Artificial Neural Networks; Springer: Berlin/Heidelberg, Germany, 2019; pp. 467–479. [Google Scholar]
  6. Chen, A.; Chen, H.Y.; Chen, C. A software improvement technique for platinum resistance thermometers. Instruments 2020, 4, 15. [Google Scholar] [CrossRef]
  7. Zheng, J.; Hu, G.; Ji, X.; Qin, X. Quintic generalized Hermite interpolation curves: Construction and shape optimization using an improved GWO algorithm. Comput. Appl. Math. 2022, 41, 1–29. [Google Scholar] [CrossRef]
  8. Abdulle, A.; Wanner, G. 200 years of least squares method. Elem. Math. 2002, 57, 45–60. [Google Scholar] [CrossRef] [Green Version]
  9. Lawson, C.L.; Hanson, R.J. Solving Least Squares Problems; SIAM: Philadelphia, PA, USA, 1995. [Google Scholar]
  10. Björck, Å. Numerical Methods for Least Squares Problems; SIAM: Philadelphia, PA, USA, 1996. [Google Scholar]
  11. Golub, G.H.; Van Loan, C.F. An analysis of the total least squares problem. SIAM J. Numer. Anal. 1980, 17, 883–893. [Google Scholar] [CrossRef] [Green Version]
  12. Van Huffel, S.; Vandewalle, J. The Total Least Squares Problem: Computational Aspects and Analysis; SIAM: Philadelphia, PA, USA, 1991. [Google Scholar]
  13. Deming, W.E. Statistical Adjustment of Data; John Wiley & Sons: New York, NY, USA, 1943. [Google Scholar]
  14. Adcock, R.J. A problem in least squares. Analyst 1878, 5, 53–54. [Google Scholar] [CrossRef]
  15. Pearson, K. LIII. On lines and planes of closest fit to systems of points in space. Lond. Edinb. Dublin Philos. Mag. J. Sci. 1901, 2, 559–572. [Google Scholar] [CrossRef] [Green Version]
  16. Petras, I.; Podlubny, I. Least squares or least circles? A comparison of classical regression and orthogonal regression. Chance 2010, 23, 38–42. [Google Scholar] [CrossRef]
  17. Scariano, S.M.; Barnett, W., II. Contrasting total least squares with ordinary least squares part I: Basic ideas and results. Math. Comput. Educ. 2003, 37, 141–158. [Google Scholar]
  18. Smith, D.; Pourfarzaneh, M.; Kamel, R. Linear regression analysis by Deming’s method. Clin. Chem. 1980, 26, 1105–1106. [Google Scholar] [CrossRef] [PubMed]
  19. Linnet, K. Performance of Deming regression analysis in case of misspecified analytical error ratio in method comparison studies. Clin. Chem. 1998, 44, 1024–1031. [Google Scholar] [CrossRef] [PubMed] [Green Version]
  20. Cantera, L.A.C.; Luna, L.; Vargas-Jarillo, C.; Garrido, R. Parameter estimation of a linear ultrasonic motor using the least squares of orthogonal distances algorithm. In Proceedings of the 16th International Conference on Electrical Engineering, Computing Science and Automatic Control, Mexico City, Mexico, 11–13 September 2019. [Google Scholar]
  21. Luna, L.; Lopez, K.; Cantera, L.; Garrido, R.; Vargas, C. Parameter estimation and delay-based control of a linear ultrasonic motor. In Robótica y Computación. Nuevos Avances; Castro-Liera, I., Cortés-Larinaga, M., Eds.; Instituto Tecnológico de La Paz: La Paz, Mexico, 2020; pp. 9–15. [Google Scholar]
  22. Garrity, K. NIST ITS-90 Thermocouple Database–SRD 60. 2000. Available online: https://data.nist.gov/od/id/ECBCC1C1302A2ED9E04306570681B10748 (accessed on 28 March 2022).
  23. Åström, K.J.; Eykhoff, P. System identification—A survey. Automatica 1971, 7, 123–162. [Google Scholar] [CrossRef] [Green Version]
  24. Englezos, P.; Kalogerakis, N. Applied Parameter Estimation for Chemical Engineers; CRC Press: Boca Raton, FL, USA, 2000. [Google Scholar]
  25. Ding, F.; Shi, Y.; Chen, T. Performance analysis of estimation algorithms of nonstationary ARMA processes. IEEE Trans. Signal Process. 2006, 54, 1041–1053. [Google Scholar] [CrossRef]
  26. Liu, P.; Liu, G. Multi-innovation least squares identification for linear and pseudo-linear regression models. IEEE Trans. Syst. Man Cybern. Part Cybern. 2010, 40, 767–778. [Google Scholar]
  27. Sun, X.; Ji, J.; Ren, B.; Xie, C.; Yan, D. Adaptive forgetting factor recursive least square algorithm for online identification of equivalent circuit model parameters of a lithium-ion battery. Energies 2019, 12, 2242. [Google Scholar] [CrossRef] [Green Version]
  28. Li, M.; Liu, X. Maximum likelihood hierarchical least squares-based iterative identification for dual-rate stochastic systems. Int. J. Adapt. Control Signal Process. 2021, 35, 240–261. [Google Scholar] [CrossRef]
  29. Zhang, X.; Ding, F. Adaptive parameter estimation for a general dynamical system with unknown states. Int. J. Robust Nonlinear Control 2020, 30, 1351–1372. [Google Scholar] [CrossRef]
  30. Kang, Z.; Ji, Y.; Liu, X. Hierarchical recursive least squares algorithms for Hammerstein nonlinear autoregressive output-error systems. Int. J. Adapt. Control Signal Process. 2021, 35, 2276–2295. [Google Scholar] [CrossRef]
  31. Burden, R.; Faires, J.; Burden, A. Numerical Analysis; Cengage Learning: Boston, MA, USA, 2016. [Google Scholar]
  32. Strang, G. Introduction to Linear Algebra; Wellesley-Cambridge Press: Wellesley, MA, USA, 2016. [Google Scholar]
  33. Eckart, C.; Young, G. The approximation of one matrix by another of lower rank. Psychometrika 1936, 1, 211–218. [Google Scholar] [CrossRef]
  34. Mirsky, L. Symmetric gauge functions and unitarily invariant norms. Q. J. Math. 1960, 11, 50–59. [Google Scholar] [CrossRef]
  35. Van Huffel, S.; Vandewalle, J. Analysis and solution of the nongeneric total least squares problem. SIAM J. Matrix Anal. Appl. 1988, 9, 360–372. [Google Scholar] [CrossRef]
  36. Van Huffel, S. On the significance of nongeneric total least squares problems. SIAM J. Matrix Anal. Appl. 1992, 13, 20–35. [Google Scholar] [CrossRef]
  37. Van Huffel, S.; Zha, H. The total least squares problem. In Handbook of Statistics; Elsevier: Amsterdam, The Netherlands, 1993; Volume 9, pp. 377–408. [Google Scholar]
  38. Uspensky, J.V. Theory of Equations; McGraw-Hill: New York, NY, USA, 1963. [Google Scholar]
  39. Atkinson, K.E. An Introduction to Numerical Analysis; John Wiley & Sons: New York, NY, USA, 2008. [Google Scholar]
  40. Dennis, J.E., Jr.; Schnabel, R.B. Numerical Methods for Unconstrained Optimization and Nonlinear Equations; SIAM: Philadelphia, PA, USA, 1996. [Google Scholar]
  41. MathWorks. Optimization Toolbox User’s Guide; MathWorks: Natick, MA, USA, 2020. [Google Scholar]
Figure 1. Orthogonal distance from a point to curve.
Figure 1. Orthogonal distance from a point to curve.
Mathematics 10 04596 g001
Table 1. Calibration polynomial of degree 1.
Table 1. Calibration polynomial of degree 1.
ParameterLSTLSOD
a 1 0.01067059195924240.01088827995240020.0106706009250352
a 0 −0.561949764591521−0.716799304506316−0.561954310248448
Table 2. Calibration polynomial of degree 2.
Table 2. Calibration polynomial of degree 2.
ParameterLSTLSOD
a 2 3.13324263891139 × 10 6 3.12919113815010 × 10 6 3.13325997351179 × 10 6
a 1 0.007493483923386220.007498701166237300.00749346705386636
a 0 −0.0811630813784754−0.0825736260294239−0.0811607801463052
Table 3. Calibration polynomial of degree 3.
Table 3. Calibration polynomial of degree 3.
ParameterLSTLSOD
a 3 −1.78686899229851 × 10 9 −1.78635025917305 × 10 9 −1.78689809449655 × 10 9
a 2 5.85107037619782 × 10 6 5.85010421131572 × 10 6 5.85111575583941 × 10 6
a 1 0.006448766665621050.006449298036442970.00644874868154519
a 0 −0.0172346997190748−0.0173148908943473−0.0172335743482728
Table 4. Calibration polynomial fitting of degree 4.
Table 4. Calibration polynomial fitting of degree 4.
ParameterLSTLSOD
a 4 3.06378459910204 × 10 12 3.06378816842890 × 10 12 3.06382882864091 × 10 12
a 3 −8.00022415925578 × 10 9 −8.00023360534995 × 10 9 −8.00031467361401 × 10 9
a 2 9.76012119529912 × 10 6 9.76012992574279 × 10 6 9.76017917221101 × 10 6
a 1 0.005679262599689950.005679259349965030.00567925074682013
a 0 0.0007655704824342800.0007659620497124380.000765883225715231
Table 5. Prediction performance of the calibration polynomials.
Table 5. Prediction performance of the calibration polynomials.
PolynomialCriteria
e max e min e ave e std R 2
n = 1 LS0.869479362553643-0.3071931286192440.2479741851360040.2951912909478900.992673799531263
TLS1.03521330212633-0.2565641117889970.2390562639015700.3066467081074960.992094154347717
OD0.869484356500207−0.3071927161927770.2479739235117590.2951912909620090.992673799530562
n = 2 LS0.222004170950508−0.07803527164548460.04180172815367290.05258329907516920.999767529752450
TLS0.223685706495914−0.07758918558223550.04166077267184070.05258634174041430.999767502848486
OD0.222000982905844−0.07803924814030690.04180208524092170.05258329910021950.999767529752229
n = 3 LS0.0988219984355953−0.03803626817389990.01986910427673060.02391418928756480.999951917942603
TLS0.0989312384058100−0.03800519604082530.01986395068673800.02391420592532180.999951917875699
OD0.0988198567741218−0.03803588126093280.01986925560778720.02391418930000850.999951917942553
n = 4 LS0.0317780798401641−0.02189701775753680.006750222331950310.007934787308494620.999994706507555
TLS0.0317775027574607−0.02189703162067500.006750238700060460.007934787309611250.999994706507553
OD0.0317770179203829−0.02189801180018590.006750252969607850.007934787315267250.999994706507546
Table 6. Calibration polynomial of degree 1 without independent coefficient.
Table 6. Calibration polynomial of degree 1 without independent coefficient.
ParameterLSTLSOD
a 1 0.009880607928564850.009880612798496020.00988061279849602
Table 7. Calibration polynomial of degree 2 without independent coefficient.
Table 7. Calibration polynomial of degree 2 without independent coefficient.
ParameterLSTLSOD
a 2 3.36630540516376 × 10 6 3.36630397586626 × 10 6 3.36632169932580 × 10 6
a 1 0.007193334937735560.007193336154931440.00719332224566322
Table 8. Calibration polynomial of degree 3 without independent coefficient.
Table 8. Calibration polynomial of degree 3 without independent coefficient.
ParameterLSTLSOD
a 3 −1.89795367055803 × 10 9 −1.89795171695059 × 10 9 −1.89797754460899 × 10 9
a 2 6.05810804037494 × 10 6 6.05810506932127 × 10 6 6.05814294168891 × 10 6
a 1 0.006334781061413060.006334782115734700.00633476947536766
Table 9. Calibration polynomial of degree 4 without independent coefficient.
Table 9. Calibration polynomial of degree 4 without independent coefficient.
ParameterLSTLSOD
a 4 3.05426851859784 × 10 12 3.05426721773752 × 10 12 3.05430880341339 × 10 12
a 3 −7.97635148760036 × 10 9 −7.97634871709437 × 10 9 −7.97643212780673 × 10 9
a 2 9.73945467428371 × 10 6 9.73945283014663 × 10 6 9.73950412699805 × 10 6
a 1 0.005686346180591750.005686346554779840.00568633723894135
Table 10. Prediction performance of the calibration polynomials without independent coefficient.
Table 10. Prediction performance of the calibration polynomials without independent coefficient.
PolynomialCriteria
e max e min e ave e std R 2
n = 1 LS0.848033164006997−0.5654363609264470.3738194375477870.4218218557078900.985040059251142
TLS0.848027982400240−0.5654379339142130.3738196291784870.4218218557180380.985040059250422
OD0.848027982400236−0.5654379339142150.3738196291784870.4218218557180380.985040059250422
n = 2 LS0.125250983373869−0.1141857439807750.05308133087304690.06184231170702370.999678453972557
TLS0.125251047806906−0.1141858871895300.05308130282525460.06184231170729440.999678453972554
OD0.125250308034846−0.1141842783428100.05308156136725240.06184231174029480.999678453972211
n = 3 LS0.0753565387608956−0.04520678719397450.02121338217103920.02467072837714190.999948827614715
TLS0.0753565991488130−0.04520686690605180.02121337349556330.02467072837722430.999948827614714
OD0.0753558692210848−0.04520593288280530.02121347387208640.02467072838780700.999948827614670
n = 4 LS0.0329525392296870−0.02183151936463720.006717677714151010.007939022576172950.999994700855144
TLS0.0329525629038775−0.02183149973756040.006717676508026200.007939022576181440.999994700855144
OD0.0329519581835754−0.02183248618203490.006717694208769130.007939022582217610.999994700855136
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Cantera-Cantera, L.A.; Vargas-Jarillo, C.; Palomino-Reséndiz, S.I.; Lozano-Hernández, Y.; Montelongo-Vázquez, C.M. A Polynomial Fitting Problem: The Orthogonal Distances Method. Mathematics 2022, 10, 4596. https://doi.org/10.3390/math10234596

AMA Style

Cantera-Cantera LA, Vargas-Jarillo C, Palomino-Reséndiz SI, Lozano-Hernández Y, Montelongo-Vázquez CM. A Polynomial Fitting Problem: The Orthogonal Distances Method. Mathematics. 2022; 10(23):4596. https://doi.org/10.3390/math10234596

Chicago/Turabian Style

Cantera-Cantera, Luis Alberto, Cristóbal Vargas-Jarillo, Sergio Isaí Palomino-Reséndiz, Yair Lozano-Hernández, and Carlos Manuel Montelongo-Vázquez. 2022. "A Polynomial Fitting Problem: The Orthogonal Distances Method" Mathematics 10, no. 23: 4596. https://doi.org/10.3390/math10234596

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop