{"id":4445,"date":"2026-08-31T12:10:00","date_gmt":"2026-08-31T12:10:00","guid":{"rendered":"https:\/\/www.mathros.net.ua\/en\/?p=4445"},"modified":"2026-08-31T15:14:07","modified_gmt":"2026-08-31T15:14:07","slug":"least-squares-method","status":"publish","type":"post","link":"https:\/\/www.mathros.net.ua\/en\/least-squares-method.html","title":{"rendered":"Least Squares Method: Function Approximation from Experimental Data"},"content":{"rendered":"<p>During experiments, function values are often known only at individual points, and the collected data may contain measurement errors. In such cases, it is not always reasonable to construct a function that passes exactly through every given point. The <a title=\"Least squares\" href=\"https:\/\/en.wikipedia.org\/wiki\/Least_squares\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">least squares method<\/a> makes it possible to find a relationship that best describes the available data as a whole, while practical examples will show how this approach is used to construct approximating polynomials and find approximate function values.<\/p>\n<h2>Approximation of Experimental Data: Problem Statement<\/h2>\n<p>Suppose that a scientific or engineering experiment produces a set of points<\/p>\n<p>\\[<br \/>\n(x_0,y_0),\\quad(x_1,y_1),\\quad\\dots,\\quad(x_n,y_n).<br \/>\n\\]<\/p>\n<p>Each value \\( x_i \\) corresponds to an experimental value \\( y_i \\), where<\/p>\n<p>\\[<br \/>\ni=0,1,\\dots,n.<br \/>\n\\]<\/p>\n<p>We need to find an approximating function<\/p>\n<p>\\[<br \/>\ny=f(x),<br \/>\n\\]<\/p>\n<p>whose values at the given points differ as little as possible from the experimental values \\( y_i \\).<\/p>\n<p>At first glance, this problem may seem similar to interpolation. However, there is an important difference between interpolation and approximation. An interpolation polynomial must pass exactly through all the given points:<\/p>\n<p>\\[<br \/>\nP(x_i)=y_i.<br \/>\n\\]<\/p>\n<p>For an approximating function, this condition is not required. In the general case, its values at the points \\( x_i \\) may differ from the given values:<\/p>\n<p>\\[<br \/>\nP(x_i)\\ne y_i.<br \/>\n\\]<\/p>\n<p>This is especially important when working with experimental data. Because of measurement errors, individual points may deviate from the overall pattern, so a function that passes exactly through every point does not always describe the relationship being studied in the best way.<\/p>\n<p>Thus, the goal of approximation is to construct a function that does not necessarily reproduce every value exactly but describes the entire data set sufficiently well.<\/p>\n<h2>Approximating Polynomial: Choosing an Approximate Relationship<\/h2>\n<p>Different mathematical relationships can be used as approximating functions. In this article, we will consider polynomial approximation, which means that we will look for an approximating function in the form of a polynomial of degree \\( m \\), where \\( m&lt;n \\):<\/p>\n<p>\\[<br \/>\nP_m(x)=a_0+a_1\\cdot x+a_2\\cdot x^2+\\dots+a_m\\cdot x^m.<br \/>\n\\]<\/p>\n<p>Here, \\( a_0,a_1,\\dots,a_m \\) are unknown coefficients that must be determined from the given experimental data.<\/p>\n<p>At the point \\( x_i \\), the value of the approximating polynomial is<\/p>\n<p>\\[<br \/>\nP_m(x_i)=a_0+a_1\\cdot x_i+a_2\\cdot x_i^2+\\dots+a_m\\cdot x_i^m.<br \/>\n\\]<\/p>\n<p>Now compare this value with the corresponding experimental value \\( y_i \\). The difference<\/p>\n<p>\\[<br \/>\nP_m(x_i)-y_i<br \/>\n\\]<\/p>\n<p>can be treated as the deviation of the approximating function from the given data at the point \\( x_i \\).<\/p>\n<p>If there are many data points, a natural question arises: how can we evaluate the quality of the approximation for the entire data set at once? To do this, we need a criterion that takes all these deviations into account at the same time.<\/p>\n<h2>Least Squares Method: Criterion for Approximation Quality<\/h2>\n<p>Individual deviations can be either positive or negative. If we simply add them together, values with opposite signs may partially or completely cancel each other out. In that case, a small sum would not necessarily mean that the approximating function describes the data well.<\/p>\n<p>To avoid this cancellation, the Least Squares Method uses the squares of the deviations. For all the given points, we form the sum<\/p>\n<p>\\[<br \/>\nS=\\sum_{i=0}^{n}\\left(P_m(x_i)-y_i\\right)^2.<br \/>\n\\]<\/p>\n<p>Substituting the expression for the approximating polynomial gives<\/p>\n<p>\\[<br \/>\nS=\\sum_{i=0}^{n}\\left(a_0+a_1\\cdot x_i+a_2\\cdot x_i^2+\\dots+a_m\\cdot x_i^m-y_i\\right)^2.<br \/>\n\\]<\/p>\n<p>The quantity \\( S \\) represents the overall deviation of the approximating polynomial from the experimental data. The smaller its value, the better the polynomial fits the given points.<\/p>\n<p>Therefore, we need to determine the coefficients \\( a_0,a_1,\\dots,a_m \\) for which the sum of squared deviations has the smallest possible value. To do this, we now move on to the conditions for minimizing the function \\( S \\).<\/p>\n<h2>Minimizing the Sum of Deviations: Constructing the System of Normal Equations<\/h2>\n<p>The function \\( S \\) depends on the unknown coefficients \\( a_0,a_1,\\dots,a_m \\). To find its minimum, we calculate the partial derivative with respect to each coefficient and set it equal to zero:<\/p>\n<p>\\[<br \/>\n\\left\\{<br \/>\n\\begin{array}{l}<br \/>\n\\dfrac{\\partial S}{\\partial a_0}=0,\\\\[6pt]<br \/>\n\\dfrac{\\partial S}{\\partial a_1}=0,\\\\[6pt]<br \/>\n\\vdots\\\\[6pt]<br \/>\n\\dfrac{\\partial S}{\\partial a_m}=0.<br \/>\n\\end{array}<br \/>\n\\right.<br \/>\n\\]<\/p>\n<p>Let us write these conditions in more detail:<\/p>\n<p>\\[<br \/>\n\\left\\{<br \/>\n\\begin{array}{l}<br \/>\n\\dfrac{\\partial S}{\\partial a_0}<br \/>\n=2\\cdot\\displaystyle\\sum_{i=0}^{n}<br \/>\n\\left(a_0+a_1\\cdot x_i+a_2\\cdot x_i^2+\\cdots+a_m\\cdot x_i^m-y_i\\right)=0,\\\\[8pt]<br \/>\n\\dfrac{\\partial S}{\\partial a_1}<br \/>\n=2\\cdot\\displaystyle\\sum_{i=0}^{n}<br \/>\n\\left(a_0+a_1\\cdot x_i+a_2\\cdot x_i^2+\\cdots+a_m\\cdot x_i^m-y_i\\right)\\cdot x_i=0,\\\\[8pt]<br \/>\n\\vdots\\\\[8pt]<br \/>\n\\dfrac{\\partial S}{\\partial a_m}<br \/>\n=2\\cdot\\displaystyle\\sum_{i=0}^{n}<br \/>\n\\left(a_0+a_1\\cdot x_i+a_2\\cdot x_i^2+\\cdots+a_m\\cdot x_i^m-y_i\\right)\\cdot x_i^m=0.<br \/>\n\\end{array}<br \/>\n\\right.<br \/>\n\\]<\/p>\n<p>Under appropriate conditions on the given data points, the solution of the resulting system determines the coefficients for which the function \\( S \\) reaches its minimum value.<\/p>\n<p>The common factor \\( 2 \\) can be removed because it does not affect the solution of the system. We then expand the sums and group the terms according to the unknown coefficients \\( a_0,a_1,\\dots,a_m \\).<\/p>\n<p>As a result, we obtain the system of normal equations:<\/p>\n<p>\\[<br \/>\n\\left\\{<br \/>\n\\begin{array}{l}<br \/>\n(n+1)\\cdot a_0+a_1\\cdot\\displaystyle\\sum_{i=0}^{n}x_i+a_2\\cdot\\displaystyle\\sum_{i=0}^{n}x_i^2+\\cdots+a_m\\cdot\\displaystyle\\sum_{i=0}^{n}x_i^m=\\displaystyle\\sum_{i=0}^{n}y_i,\\\\[8pt]<br \/>\na_0\\cdot\\displaystyle\\sum_{i=0}^{n}x_i+a_1\\cdot\\displaystyle\\sum_{i=0}^{n}x_i^2+a_2\\cdot\\displaystyle\\sum_{i=0}^{n}x_i^3+\\cdots+a_m\\cdot\\displaystyle\\sum_{i=0}^{n}x_i^{m+1}=\\displaystyle\\sum_{i=0}^{n}y_i\\cdot x_i,\\\\[8pt]<br \/>\n\\vdots\\\\[8pt]<br \/>\na_0\\cdot\\displaystyle\\sum_{i=0}^{n}x_i^m+a_1\\cdot\\displaystyle\\sum_{i=0}^{n}x_i^{m+1}+a_2\\cdot\\displaystyle\\sum_{i=0}^{n}x_i^{m+2}+\\cdots+a_m\\cdot\\displaystyle\\sum_{i=0}^{n}x_i^{2\\cdot m}=\\displaystyle\\sum_{i=0}^{n}y_i\\cdot x_i^m.<br \/>\n\\end{array}<br \/>\n\\right.<br \/>\n\\]<\/p>\n<p>All sums containing \\( x_i \\) and \\( y_i \\) are calculated from the given experimental data. Once these sums have been evaluated, we obtain a system of linear equations for the unknown coefficients \\( a_0,a_1,\\dots,a_m \\).<\/p>\n<p>By solving this system, we determine the coefficients of the approximating polynomial<\/p>\n<p>\\[<br \/>\nP_m(x)=a_0+a_1\\cdot x+a_2\\cdot x^2+\\dots+a_m\\cdot x^m.<br \/>\n\\]<\/p>\n<p>The solution of the system of normal equations determines the polynomial that best fits the given data according to the least-squares criterion. Now let us see how this procedure is applied in practice.<\/p>\n<h2>Least Squares Method: Practical Examples of Function Approximation<\/h2>\n<p>Now let us apply the system of normal equations derived above to specific data sets. First, we will construct a first-degree polynomial, then consider quadratic approximation, and finally use the resulting relationship to calculate an approximate function value.<\/p>\n<h3 class=\"example\">Example 1. Use the least squares method to find a first-degree polynomial that approximates the function given in the table<\/h3>\n<table class=\"simple-table\">\n<thead>\n<tr>\n<th>\\( i \\)<\/th>\n<th>\\( x_i \\)<\/th>\n<th>\\( y_i \\)<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\\( 0 \\)<\/td>\n<td>\\( 1 \\)<\/td>\n<td>\\( 3 \\)<\/td>\n<\/tr>\n<tr>\n<td>\\( 1 \\)<\/td>\n<td>\\( 2 \\)<\/td>\n<td>\\( 3 \\)<\/td>\n<\/tr>\n<tr>\n<td>\\( 2 \\)<\/td>\n<td>\\( 3 \\)<\/td>\n<td>\\( 6 \\)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>We will look for the approximating function in the form<\/p>\n<p>\\[<br \/>\nP_1(x)=a_0+a_1\\cdot x.<br \/>\n\\]<\/p>\n<p>For a first-degree polynomial, the system of normal equations has the form<\/p>\n<p>\\[<br \/>\n\\left\\{<br \/>\n\\begin{array}{l}<br \/>\n3\\cdot a_0+a_1\\cdot\\sum x_i=\\sum y_i,\\\\[6pt]<br \/>\na_0\\cdot\\sum x_i+a_1\\cdot\\sum x_i^2=\\sum x_i\\cdot y_i.<br \/>\n\\end{array}<br \/>\n\\right.<br \/>\n\\]<\/p>\n<p>Let us calculate the required sums:<\/p>\n<p>\\[<br \/>\n\\begin{gathered}<br \/>\n\\sum x_i=1+2+3=6,\\\\[4pt]<br \/>\n\\sum x_i^2=1^2+2^2+3^2=14,\\\\[4pt]<br \/>\n\\sum y_i=3+3+6=12,\\\\[4pt]<br \/>\n\\sum x_i\\cdot y_i=1\\cdot3+2\\cdot3+3\\cdot6=27.<br \/>\n\\end{gathered}<br \/>\n\\]<\/p>\n<p>Substitute these values into the system of normal equations:<\/p>\n<p>\\[<br \/>\n\\left\\{<br \/>\n\\begin{array}{l}<br \/>\n3\\cdot a_0+6\\cdot a_1=12,\\\\[6pt]<br \/>\n6\\cdot a_0+14\\cdot a_1=27.<br \/>\n\\end{array}<br \/>\n\\right.<br \/>\n\\]<\/p>\n<p>Multiply the first equation by \\( 2 \\):<\/p>\n<p>\\[<br \/>\n6\\cdot a_0+12\\cdot a_1=24.<br \/>\n\\]<\/p>\n<p>Subtract it from the second equation:<\/p>\n<p>\\[<br \/>\n2\\cdot a_1=3.<br \/>\n\\]<\/p>\n<p>Hence,<\/p>\n<p>\\[<br \/>\na_1=1.5.<br \/>\n\\]<\/p>\n<p>Substitute the obtained value into the first equation:<\/p>\n<p>\\[<br \/>\n\\begin{gathered}<br \/>\n3\\cdot a_0+6\\cdot1.5=12,\\\\[4pt]<br \/>\n3\\cdot a_0=3,\\\\[4pt]<br \/>\na_0=1.<br \/>\n\\end{gathered}<br \/>\n\\]<\/p>\n<p>Therefore, the required approximating polynomial is<\/p>\n<p>\\[<br \/>\nP_1(x)=1+1.5\\cdot x.<br \/>\n\\]<\/p>\n<h3 class=\"example\">Example 2. Use the least squares method to find a second-degree polynomial for the function given in the table<\/h3>\n<table class=\"simple-table\">\n<thead>\n<tr>\n<th>\\( i \\)<\/th>\n<th>\\( x_i \\)<\/th>\n<th>\\( y_i \\)<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\\( 0 \\)<\/td>\n<td>\\( -2 \\)<\/td>\n<td>\\( 5 \\)<\/td>\n<\/tr>\n<tr>\n<td>\\( 1 \\)<\/td>\n<td>\\( -1 \\)<\/td>\n<td>\\( 2 \\)<\/td>\n<\/tr>\n<tr>\n<td>\\( 2 \\)<\/td>\n<td>\\( 0 \\)<\/td>\n<td>\\( 1 \\)<\/td>\n<\/tr>\n<tr>\n<td>\\( 3 \\)<\/td>\n<td>\\( 1 \\)<\/td>\n<td>\\( 2 \\)<\/td>\n<\/tr>\n<tr>\n<td>\\( 4 \\)<\/td>\n<td>\\( 2 \\)<\/td>\n<td>\\( 4 \\)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>We will look for the approximating function in the form<\/p>\n<p>\\[<br \/>\nP_2(x)=a_0+a_1\\cdot x+a_2\\cdot x^2.<br \/>\n\\]<\/p>\n<p>For a second-degree polynomial, the system of normal equations has the form<\/p>\n<p>\\[<br \/>\n\\left\\{<br \/>\n\\begin{array}{l}<br \/>\n5\\cdot a_0+a_1\\cdot\\sum x_i+a_2\\cdot\\sum x_i^2=\\sum y_i,\\\\[6pt]<br \/>\na_0\\cdot\\sum x_i+a_1\\cdot\\sum x_i^2+a_2\\cdot\\sum x_i^3=\\sum x_i\\cdot y_i,\\\\[6pt]<br \/>\na_0\\cdot\\sum x_i^2+a_1\\cdot\\sum x_i^3+a_2\\cdot\\sum x_i^4=\\sum x_i^2\\cdot y_i.<br \/>\n\\end{array}<br \/>\n\\right.<br \/>\n\\]<\/p>\n<p>First, let us calculate the sums of powers of \\( x_i \\):<\/p>\n<p>\\[<br \/>\n\\begin{gathered}<br \/>\n\\sum x_i=-2-1+0+1+2=0,\\\\[4pt]<br \/>\n\\sum x_i^2=(-2)^2+(-1)^2+0^2+1^2+2^2=10,\\\\[4pt]<br \/>\n\\sum x_i^3=(-2)^3+(-1)^3+0^3+1^3+2^3=0,\\\\[4pt]<br \/>\n\\sum x_i^4=(-2)^4+(-1)^4+0^4+1^4+2^4=34.<br \/>\n\\end{gathered}<br \/>\n\\]<\/p>\n<p>Now calculate the sums that contain the values \\( y_i \\):<\/p>\n<p>\\[<br \/>\n\\begin{gathered}<br \/>\n\\sum y_i=5+2+1+2+4=14,\\\\[4pt]<br \/>\n\\sum x_i\\cdot y_i=(-2)\\cdot5+(-1)\\cdot2+0\\cdot1+1\\cdot2+2\\cdot4=-2,\\\\[4pt]<br \/>\n\\sum x_i^2\\cdot y_i=4\\cdot5+1\\cdot2+0\\cdot1+1\\cdot2+4\\cdot4=40.<br \/>\n\\end{gathered}<br \/>\n\\]<\/p>\n<p>Substitute these values into the system of normal equations:<\/p>\n<p>\\[<br \/>\n\\left\\{<br \/>\n\\begin{array}{l}<br \/>\n5\\cdot a_0+10\\cdot a_2=14,\\\\[6pt]<br \/>\n10\\cdot a_1=-2,\\\\[6pt]<br \/>\n10\\cdot a_0+34\\cdot a_2=40.<br \/>\n\\end{array}<br \/>\n\\right.<br \/>\n\\]<\/p>\n<p>From the second equation, we find<\/p>\n<p>\\[<br \/>\na_1=-0.2.<br \/>\n\\]<\/p>\n<p>To find \\( a_0 \\) and \\( a_2 \\), we use the first and third equations. Multiply the first equation by \\( 2 \\):<\/p>\n<p>\\[<br \/>\n10\\cdot a_0+20\\cdot a_2=28.<br \/>\n\\]<\/p>\n<p>Subtract the resulting equation from the third equation:<\/p>\n<p>\\[<br \/>\n14\\cdot a_2=12.<br \/>\n\\]<\/p>\n<p>Hence,<\/p>\n<p>\\[<br \/>\na_2\\approx0.857.<br \/>\n\\]<\/p>\n<p>Substitute the obtained value into the first equation:<\/p>\n<p>\\[<br \/>\n5\\cdot a_0+10\\cdot0.857\\approx14,<br \/>\n\\]<\/p>\n<p>which gives<\/p>\n<p>\\[<br \/>\na_0\\approx1.086.<br \/>\n\\]<\/p>\n<p>Therefore, the second-degree approximating polynomial is<\/p>\n<p>\\[<br \/>\nP_2(x)=1.086-0.2\\cdot x+0.857\\cdot x^2.<br \/>\n\\]<\/p>\n<h3 class=\"example\">Example 3. For the given tabular data, use the least squares method to construct a first-degree polynomial and then use it to find an approximate function value at \\( x=3 \\)<\/h3>\n<table class=\"simple-table\">\n<thead>\n<tr>\n<th>\\( i \\)<\/th>\n<th>\\( x_i \\)<\/th>\n<th>\\( y_i \\)<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\\( 0 \\)<\/td>\n<td>\\( 0 \\)<\/td>\n<td>\\( 1.5 \\)<\/td>\n<\/tr>\n<tr>\n<td>\\( 1 \\)<\/td>\n<td>\\( 1 \\)<\/td>\n<td>\\( 1 \\)<\/td>\n<\/tr>\n<tr>\n<td>\\( 2 \\)<\/td>\n<td>\\( 2 \\)<\/td>\n<td>\\( 3.5 \\)<\/td>\n<\/tr>\n<tr>\n<td>\\( 3 \\)<\/td>\n<td>\\( 4 \\)<\/td>\n<td>\\( 5 \\)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>We will look for the approximating function in the form<\/p>\n<p>\\[<br \/>\nP_1(x)=a_0+a_1\\cdot x.<br \/>\n\\]<\/p>\n<p>Since we already derived the system of normal equations for a first-degree polynomial in the previous example, we can immediately calculate the required sums:<\/p>\n<p>\\[<br \/>\n\\begin{gathered}<br \/>\n\\sum x_i=0+1+2+4=7,\\\\[4pt]<br \/>\n\\sum x_i^2=0^2+1^2+2^2+4^2=21,\\\\[4pt]<br \/>\n\\sum y_i=1.5+1+3.5+5=11,\\\\[4pt]<br \/>\n\\sum x_i\\cdot y_i=0\\cdot1.5+1\\cdot1+2\\cdot3.5+4\\cdot5=28.<br \/>\n\\end{gathered}<br \/>\n\\]<\/p>\n<p>Substitute these values into the system of normal equations:<\/p>\n<p>\\[<br \/>\n\\left\\{<br \/>\n\\begin{array}{l}<br \/>\n4\\cdot a_0+7\\cdot a_1=11,\\\\[6pt]<br \/>\n7\\cdot a_0+21\\cdot a_1=28.<br \/>\n\\end{array}<br \/>\n\\right.<br \/>\n\\]<\/p>\n<p>To eliminate \\( a_0 \\), multiply the first equation by \\( 7 \\) and the second equation by \\( 4 \\):<\/p>\n<p>\\[<br \/>\n\\left\\{<br \/>\n\\begin{array}{l}<br \/>\n28\\cdot a_0+49\\cdot a_1=77,\\\\[6pt]<br \/>\n28\\cdot a_0+84\\cdot a_1=112.<br \/>\n\\end{array}<br \/>\n\\right.<br \/>\n\\]<\/p>\n<p>Subtract the first equation from the second:<\/p>\n<p>\\[<br \/>\n35\\cdot a_1=35.<br \/>\n\\]<\/p>\n<p>Hence,<\/p>\n<p>\\[<br \/>\na_1=1.<br \/>\n\\]<\/p>\n<p>Substitute the obtained value into the first equation:<\/p>\n<p>\\[<br \/>\n\\begin{gathered}<br \/>\n4\\cdot a_0+7=11,\\\\[4pt]<br \/>\n4\\cdot a_0=4,\\\\[4pt]<br \/>\na_0=1.<br \/>\n\\end{gathered}<br \/>\n\\]<\/p>\n<p>Therefore, the approximating polynomial is<\/p>\n<p>\\[<br \/>\nP_1(x)=1+x.<br \/>\n\\]<\/p>\n<p>Now use the obtained relationship to calculate the approximate function value at (x=3):<\/p>\n<p>\\[<br \/>\nP_1(3)=1+3=4.<br \/>\n\\]<\/p>\n<p>Therefore,<\/p>\n<p>\\[<br \/>\nf(3)\\approx4.<br \/>\n\\]<\/p>\n<h2>Other Function Approximation Methods: Topics to Explore Next<\/h2>\n<p>After learning about the least squares method, it is worth exploring other ways to approximate functions given in tabular form. The following topics will help you compare different approaches to calculating function values between known nodes.<\/p>\n<ol>\n<li><a title=\"Linear interpolation\" href=\"https:\/\/www.mathros.net.ua\/en\/\">Linear Interpolation: Approximating a Function Between Neighboring Nodes<\/a> \u2014 Learn how to construct a linear relationship from two neighboring tabular values and use it to approximate the function between them.<\/li>\n<li><a title=\"Quadratic interpolation\" href=\"https:\/\/www.mathros.net.ua\/en\/\">Quadratic Interpolation: Calculating Intermediate Function Values<\/a> \u2014 See how to construct a quadratic polynomial from several nodes and use it to approximate intermediate function values.<\/li>\n<li><a title=\"Cubic spline interpolation\" href=\"https:\/\/www.mathros.net.ua\/en\/\">Cubic Spline Interpolation: Approximating a Function Without Sharp Changes<\/a> \u2014 Learn how cubic splines connect separate intervals to form a smooth curve that passes through the given tabular points.<\/li>\n<\/ol>\n<h2>Least Squares Method: From Flowchart to Program Code<\/h2>\n<p>Interested in programming? Then try implementing the algorithm shown in the flowchart using your favorite programming language. The program should read the tabular data, construct an approximating polynomial using the least squares method, determine its coefficients, and calculate its value at a given point. <em>Pascal<\/em>, <a title=\"What is Python\" href=\"https:\/\/www.mathros.net.ua\/en\/what-is-python.html\"><em>Python<\/em><\/a>, <em>JavaScript<\/em>, or <em>C++<\/em> \u2014 the choice is yours. This way, you will not only test your understanding of the algorithm but also see how mathematical calculations can be transformed into a working program.<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"size-full wp-image-4464 aligncenter\" src=\"https:\/\/www.mathros.net.ua\/en\/wp-content\/uploads\/2026\/08\/least-squares-method1.jpg\" alt=\"Flowchart of the algorithm for calculating the value of a function given in tabular form using the least squares method\" width=\"600\" height=\"1462\" srcset=\"https:\/\/www.mathros.net.ua\/en\/wp-content\/uploads\/2026\/08\/least-squares-method1.jpg 600w, https:\/\/www.mathros.net.ua\/en\/wp-content\/uploads\/2026\/08\/least-squares-method1-123x300.jpg 123w, https:\/\/www.mathros.net.ua\/en\/wp-content\/uploads\/2026\/08\/least-squares-method1-420x1024.jpg 420w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>During experiments, function values are often known only at individual points, and the collected data may contain measurement errors. In<\/p>\n","protected":false},"author":1,"featured_media":4466,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"template-centered.php","format":"standard","meta":{"footnotes":""},"categories":[574],"tags":[585,584,583,586,134],"class_list":["post-4445","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-function-approximation-methods","tag-approximating-polynomial","tag-function-approximation","tag-least-squares-method","tag-numerical-approximation","tag-numerical-methods"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.mathros.net.ua\/en\/wp-json\/wp\/v2\/posts\/4445","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mathros.net.ua\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mathros.net.ua\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mathros.net.ua\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mathros.net.ua\/en\/wp-json\/wp\/v2\/comments?post=4445"}],"version-history":[{"count":18,"href":"https:\/\/www.mathros.net.ua\/en\/wp-json\/wp\/v2\/posts\/4445\/revisions"}],"predecessor-version":[{"id":4465,"href":"https:\/\/www.mathros.net.ua\/en\/wp-json\/wp\/v2\/posts\/4445\/revisions\/4465"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mathros.net.ua\/en\/wp-json\/wp\/v2\/media\/4466"}],"wp:attachment":[{"href":"https:\/\/www.mathros.net.ua\/en\/wp-json\/wp\/v2\/media?parent=4445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mathros.net.ua\/en\/wp-json\/wp\/v2\/categories?post=4445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mathros.net.ua\/en\/wp-json\/wp\/v2\/tags?post=4445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}