Newton's Divided Differences Interpolation Method
Newton's Divided Differences Interpolation Method
学 院:土木工程学院
系 所:桥梁工程系
姓 名:杜别 2493252
指导老师:陈艾荣
2024 年 12 月 11 日
Table of contents
Abstract
Missing data or values is a common issue in processing a dataset. It is also occurred in the
IntelligEnSia system, which is a system that utilizes and optimizes the electricity consumption
data. The problems occur when the data that are being sent by the sensor(s) to the web server
are missing due to the unstable internet connection. It is an essential matter, since we want to
capture the data by real time. The data set are useful to learn the pattern of the electricity
consumption and predict the next electricity demand. Therefore, to overcome these problems
we try to propose a method to complete the missing data by applying Newton’s divided-
differences interpolation method. So, this research may support to predict the electricity
consumption and to create an effective prediction model by solving the problem of missing
data.
Introduction
Missing data is identically referred to a missing data mechanism, observation process or
selection process. In context of missing data process, it is lead to a missing data theory that
has an impact on learning, inference and prediction. There are two fundamental categories of
missing data: random and un-random missing data. In case of random missing data, the
process can be ignored and inference can be based only by the observed data. In this case, in
many common generative models the computing results are traceable. For the un-random
missing data, the missing one will be ignored. Missing data in the data set used for any data
analysis is serious issue for any research. There are various methods that are used for finding
the missing data in data set and these are having different conditions for finding missing data
from these methods some of methods are for handling the missing data and some of methods
are for interpolating or predicting the missing value in data set (Manembu, Kewo et al. 2015).
In this paper is on how to solve electricity consumption missing data based on IntelligEnSia
using Newton’s divided-differences interpolation method. Then objective is to interpolate
missing data in the electricity consumption based on the observed data from IntelligEnSia
using Newton’s divided-differences interpolation method.
I. Background
Numerical analysis is a branch of mathematics that solves continuous problems using numeric
approximation. It involves designing methods that give approximate but accurate numeric
solutions, which is useful in cases where the exact solution is impossible or prohibitively
expensive to calculate. Numerical analysis also involves characterizing the convergence,
accuracy, stability, and computational complexity of these methods. (Chapra 2011).
The numerical analysis method used to solve the problem of this paper is: Newton’s Divided-
differences interpolation method. It is among the most popular and useful method used for
the interpolations.
I.1. Newton’s divided-difference interpolation method
Newton's divided-differences interpolation is based on the concept of finite differences and
stems from a reformulation of the Lagrange interpolation polynomial into a more modular and
computationally efficient form. This theorem states that for a set of distinct points, there exists
a unique polynomial of degree at most that passes through all these points. Newton proposed
a constructive method to express this polynomial using divided differences, which measure
the variations in -values between the -points. These Divided differences are recursively
calculated coefficients representing the average rate of change between multiple points. It is
used to compute the coefficients of the interpolation polynomial. The polynomial is expressed
in a hierarchical structure, with successive terms based on divided differences. This form
relies on the modular structure of the products, making computations efficient and allowing
for easy addition of new data points (Chapra 2018).
Newton's method is mathematically better to Lagrange interpolation in terms of the resulting
polynomial and it is more practical for:
Incremental computations (adding a new point does not require recalculating the entire
polynomial).
Handling unequally spaced data points.
I.2. Newton’s divided-difference interpolating polynomial
Newton’s divided-difference interpolating polynomial is among the most popular and useful
forms. Before presenting the general equation, we will introduce the first and second-order
versions because of their simple visual interpretation (Burden and Faires 2010).
I.2.1. Linear Interpolation
The simplest form of interpolation is to connect two data points with a straight line. This
technique, called linear interpolation, is depicted graphically in Fig. 1. Using similar triangle
f 1 ( x )−f ( x 0 ) f ( x 1 )−f ( x 0 )
=
x −x 0 x 1−x 0
( 1)
which can be rearranged to yield
f ( x 1) −f ( x 0 )
f 1 ( x )=f ( x 0 ) + ( x−x 0 )
x 1−x 0
( 2)
which is a linear-interpolation formula. The notation f 1 ( x ) designates that this is a first order
interpolating polynomial. Notice that besides representing the slope of the line connecting the
points, the term [ f 1 ( x )−f ( x 0 ) ] /( x−x 0) is a finite-divided-difference approximation of the first
derivative. In general, the smaller the interval between the data points, the better the
approximation. This is due to the fact that, as the interval decreases, a continuous function
will be better approximated by a straight line.
Figure 1 : Graphical depiction of linear interpolation. The shaded areas indicate the similar triangles used in Eq.2
Where
a 0=b 0−b1 x 0+ b2 x0 x 1
a 1=b1−b2 x 0 −b2 x 1
a 2=b2
A simple procedure can be used to determine the values of the coefficients. For b 0, Eq.3 with
x−x 0 can be used to compute
b 0=f ( x 0 )
(4 )
Eq. 4 can be substituted into Eq.3, which can be evaluated at x−x 1 for
f ( x 1) −f ( x 0 )
b 1=
x 1−x 0
(5)
Finally, Eq. 4 and 5 can be substituted into Eq. 3, which can be evaluated at x=x 2 and solved
(after some algebraic manipulations) for x−x 2
f ( x 2 )−f ( x 1 ) f ( x 1) −f ( x 0 )
−
x2− x1 x 1−x 0
b 2=
x 2−x 0
(6)
Notice that, as was the case with linear interpolation, b 1 still represents the slope of the line
connecting points x 0 and x 1. Thus, the first two terms of Eq. 3 are equivalent to linear
interpolation from x 0 to x 1., as specified previously in Eq. 2. The last term, b 2 ( x−x 0 ) ( x−x 1 ),
introduces the second-order curvature into the formula.
I.2.3. General Form of Newton’s Divided-difference Interpolating Polynomials
The preceding analysis can be generalized to fit an nth-order polynomial to n + 1 data points.
The nth-order polynomial is (Chapra 2018):
f n ( x )=b0 +b 1 ( x−x 0 ) +…+ bn ( x−x 0 ) ( x−x 1 ) … ( x−x n−1)
(7 )
As was done previously with the linear and quadratic interpolations, data points can be used
to evaluate the coefficients b 0, b 1, . . . , b n. For an n th-order polynomial, n+1 data points are
required: [ x 0, f ( x 0 ) ], [ x 1, f ( x 1 )], . . . , [ x n , f ( x n )]. We use these data points and the following
equations to evaluate the coefficients:
b 0=f ( x 0 )
(8 )
b 1=f [ x 1 , x 0 ]
(9 )
b 2=f [ x 2 , x 1 , x 0 ]
( 10 )
.
.
.
b n=f [ x n , x n−1 , … , x 0 ]
( 11)
where the bracketed function evaluations are finite divided differences. For example, the first
finite divided difference is represented generally as
f ( x i )−f ( x j )
f [ x i , x j ]=
x i−x j
( 12 )
The second finite divided difference, which represents the difference of two first divided
differences, is expressed generally as
f [x i , x j ]−f [ x j , x k ]
f [ x i , x j , x k ]=
x i−x k
( 13 )
f [ xn , x n−1 , … , x 0 ]−f [ x n−1 , x n−2 , … , x 0 ]
f [ x n , xn −1 , … , x0 ]=
x n−x 0
( 14 )
Figure 2 : Graphical depiction of the recursive nature of finite divided differences (Chapra 2018).
These differences can be used to evaluate the coefficients in Eq. 8 through 11, which can then
be substituted into Eq. 7 to yield the interpolating polynomial
f n ( x )=f ( x 0 ) + ( x−x 0 ) f [ x 1 , x 0 ] + ( x−x 0 ) ( x−x 1 ) f [ x 2 , x 1 , x 0 ] +…
II. IntelligEnSia
IntelligEnSia is an Information Communication and Technology (ICT) innovative solution
that can control and monitor the energy consumption through the internet connection on web
and mobile platforms. It can also adapt and learn the user consumption profile. Based on the
related data, IntelligEnSia can produce intelligence flexible reporting. IntelligEnSia’s
application: Monitoring IntelligEnSia optimized the data by providing a flexible reporting for
the user. It contains the information of Voltages, current and power which are the basic
variables in measuring the energy consumption. Voltage and current can be captured by the
voltage and current sensors that have been plug in at home or building. While Power, is the
multiplication result of voltage and current (Manembu, Kewo et al. 2015).
P=I .V
( 16 )
Where P : power (watt), I : current (Ampere), V : voltage (volt)
Experiments and results
IntelligEnSia Data Monitoring
In the data monitoring, as a result of unstable internet connection we find out some missing
data as captured on the www.intelligensia.org:
V o l t a ge (V o l t )
0
17:40:00 17:40:30 17:41:00 17:41:30 17:42:00 17:42:30 17:43:00
2.592 2.592
2.187 2.187
1.782
1.692
0
17:40:00 17:40:30 17:41:00 17:41:30 17:42:00 17:42:30 17:43:00
P o w e r (Wa tt )
570.24 570.24
494.262 494.262
395.604
375.624
0
17:40:00 17:40:30 17:41:00 17:41:30 17:42:00 17:42:30 17:43:00
To obtain the energy consumption data in a house or building, IntelligEnSia captures real time
data with the interval of 30 seconds. It may benefit to the customer who wants to know how
much power that he/she has used by real time. In the real time capturing process, sometimes
the data are unsuccessfully captured by the IntelligEnSia server due to the down of electricity
by the provider or unstable internet connection. In this case, if server cannot capture the
voltage and current data, it is then automatically cannot count the power. Our focus is on the
missing data when the unstable internet connection is occurred. Table below displays that on
17:42:00, the data of Voltage, Current and Power are valued null, which may affect the power
measurement result (Manembu, Kewo et al. 2015).
Table 1 : The example of missing data in IntelligEnSia (Manembu, Kewo et al. 2015)
III. Methodology
Newton’s divided-difference Interpolation is the interpolation technique that using the
polynomial functions, so there are some required steps:
Selection of the origin of your coordinate system:
To get the idea of interpolation or missing value in the set data, it’s necessary de plot the set
data in the graph. The origin of this coordinate system is very important to plot the graph. It
permits also to get the first point of your set data(x 0 ; f ( x 0 ) )
IV. Calculation
More the order is high, more we need some software or some codes to calculate the missing
data. It’s simple and rapid. For this paper, I used the Python and MATLAB codes to solve this
problem. And this part is only focus on how to make a code for this calculation.
The codes (Python or MATLAB) are based on the recursive property of this method shown in
the figure below:
Table 3 : recursive graphic of Newton’s divided-differences interpolation method (Burden and Faires 2010)
import numpy as np
p[i,0]=x[i]
p[i,1]=y[i]
# print(p) ## can check the complete Tree table here for NDDP
b=p[0][1:]#This vector contains the unknown coefficients in the polynomial which are the top elements of
each column.
print("b= ",b)
print("x= ",x)
lst=[] # list where we will append the values of prouct terms
t=1
for i in range(len(x)):
t*=(value-x[i]) ##(x-x0), (x-x0)(x-x1), (x-x0)(x-x1)(x-x2) etc..
lst.append(t)
print("The list of product elements ",lst,end = ' ')
## creating a general function
f=b[0]
for k in range(1,len(b)):
f+=b[k]*lst[k-1] ## important**[k-1]** not k because in list we use one step earlier element. For example
for b1 we have to use (x-x0), for b2, we use (x-x0)(x-x1) for b3 we use (x-x0)(x-x1)(x2)
print("The value of polynomial: ","%.3f"%f)
IV.2. MATLAB code
It’s the same procedure like Python
% Newton's Divided Difference Interpolation Method
for j = 2:n
for i = 1:n-j+1
div_diff(i, j) = (div_diff(i+1, j-1) - div_diff(i, j-1)) / (x(i+j-1) - x(i));
end
end
V. Results
For this part, let’s use the set data for the table 2 and apply the formula in Python, we will get
at x=120 seconds (missing point):
Current I =2.192 Ampere
Voltage U =218.829Volts
Power P=U . I =479.673168Watts
So, with the missing value obtained, we will get the table and the figures below
Table 4 : Correction of the set data of the table 1
Voltage (Volt)
226 226
222 222
220 220
218.829
Current (Ampere)
2.592 2.592
2.187 2.187 2.192
1.692 1.782
375.624 395.604