SlideShare a Scribd company logo
Theoretical and Practical Bounds on the Initial Value of
Skew-Compensated Clock for Clock Skew Compensation
Algorithm Immune to Floating-Point Precision Loss
Kyeong Soo (Joseph) Kim
(With Seungyeop Kang)
School of Advanced Technology
Xi’an Jiaotong-Liverpool University
Department of Mathematics
Chungnam National University
January 25, 2023
1 / 47
Theoretical and Practical Bounds on the Initial Value of Skew-Compensated Clock for Clock Skew Compensation Algorithm Immune to Floating-Point Precision Loss (Extended Version)
Outline
Background
Bresenham’s Line Drawing Algorithm
Review of Clock Skew Compensation Based on Extended Bresenham’s
Algorithm
Clock Skew Compensation with Optimal Error Bounds
Numerical Examples
Conclusions
3 / 47
Next . . .
Background
Bresenham’s Line Drawing Algorithm
Review of Clock Skew Compensation Based on Extended Bresenham’s
Algorithm
Clock Skew Compensation with Optimal Error Bounds
Floating-Point Numbers
Bounds on The Initial Value of Skew-Compensated Clock
Numerical Examples
Conclusions
4 / 47
Target Environment: WSN/IoT Nodes
▶ Measuring data and/or detect events
with sensors and connected to a
WSN/Internet only through wireless
channels.
▶ Limited in processing and
battery-powered.
5 / 47
Target Environment: WSN/IoT Nodes
▶ Measuring data and/or detect events
with sensors and connected to a
WSN/Internet only through wireless
channels.
▶ Limited in processing and
battery-powered.
5 / 47
Effect of Clock Skew on Time Synchronization
Ideal
Clock
Faster
Clock
Slower
Clock
Local
Time
Reference
Time
Time
Synchronization
Error
6 / 47
Next . . .
Background
Bresenham’s Line Drawing Algorithm
Review of Clock Skew Compensation Based on Extended Bresenham’s
Algorithm
Clock Skew Compensation with Optimal Error Bounds
Floating-Point Numbers
Bounds on The Initial Value of Skew-Compensated Clock
Numerical Examples
Conclusions
7 / 47
Raster vs. Vector Graphics1
1
“Vector graphics,” Wikipedia: The Free Encyclopedia, Wikimedia Foundation,
Accessed: Aug. 1, 2022.
8 / 47
Drawing A Straight Line Between Two Points2
2
“How to implement Bresenham’s algorithm as a system of equations?,”
StackExchange, Accessed: Aug. 1, 2022.
9 / 47
Bresenham’s Algorithm3
I
▶ An algorithm determining the points of
a 2-dimensional raster to approximate a
straight line between two points.
▶ Implementable using only integer
addition, subtraction, and bit shifting.
▶ An example of incremental error
algorithms using simple integer
arithmetic to update an error term that
determines if another quantity is
incremented to avoid expensive
division or multiplication operations. Calcomp 565 drum plotter (circa 1959).
3
J. E. Bresenham, IBM Systems Journal, vol. 4, no. 1 pp. 25–30, 1965.
10 / 47
Bresenham’s Algorithm3
I
▶ An algorithm determining the points of
a 2-dimensional raster to approximate a
straight line between two points.
▶ Implementable using only integer
addition, subtraction, and bit shifting.
▶ An example of incremental error
algorithms using simple integer
arithmetic to update an error term that
determines if another quantity is
incremented to avoid expensive
division or multiplication operations. Calcomp 565 drum plotter (circa 1959).
3
J. E. Bresenham, IBM Systems Journal, vol. 4, no. 1 pp. 25–30, 1965.
10 / 47
Bresenham’s Algorithm3
I
▶ An algorithm determining the points of
a 2-dimensional raster to approximate a
straight line between two points.
▶ Implementable using only integer
addition, subtraction, and bit shifting.
▶ An example of incremental error
algorithms using simple integer
arithmetic to update an error term that
determines if another quantity is
incremented to avoid expensive
division or multiplication operations. Calcomp 565 drum plotter (circa 1959).
3
J. E. Bresenham, IBM Systems Journal, vol. 4, no. 1 pp. 25–30, 1965.
10 / 47
Bresenham’s Algorithm II
Consider two points D1(x1, y1) and
D2(x2, y2) in the first octant.
▶ In the new coordinate system
obtained by translation of the
origin to D1, the new coordinates
of D2 are given by
(∆a, ∆b)=(x2−x1, y2−y1).
▶ For the first octant, ∆a≥∆b≥0.
▶ Plotter movements are limited to
M1 and M2 in this case.
Possible plotter movements.
Sequence of plotter movements in the first octant.
11 / 47
Bresenham’s Algorithm II
Consider two points D1(x1, y1) and
D2(x2, y2) in the first octant.
▶ In the new coordinate system
obtained by translation of the
origin to D1, the new coordinates
of D2 are given by
(∆a, ∆b)=(x2−x1, y2−y1).
▶ For the first octant, ∆a≥∆b≥0.
▶ Plotter movements are limited to
M1 and M2 in this case.
Possible plotter movements.
Sequence of plotter movements in the first octant.
11 / 47
Bresenham’s Algorithm II
Consider two points D1(x1, y1) and
D2(x2, y2) in the first octant.
▶ In the new coordinate system
obtained by translation of the
origin to D1, the new coordinates
of D2 are given by
(∆a, ∆b)=(x2−x1, y2−y1).
▶ For the first octant, ∆a≥∆b≥0.
▶ Plotter movements are limited to
M1 and M2 in this case.
Possible plotter movements.
Sequence of plotter movements in the first octant.
11 / 47
Bresenham’s Algorithm II
Consider two points D1(x1, y1) and
D2(x2, y2) in the first octant.
▶ In the new coordinate system
obtained by translation of the
origin to D1, the new coordinates
of D2 are given by
(∆a, ∆b)=(x2−x1, y2−y1).
▶ For the first octant, ∆a≥∆b≥0.
▶ Plotter movements are limited to
M1 and M2 in this case.
Possible plotter movements.
Sequence of plotter movements in the first octant.
11 / 47
Bresenham’s Algorithm III
▶ We can calculate ▽i using the following simple recursive relation:
▽0 = 2∆b − ∆a,
▽i+1 =







▽i + 2∆b − 2∆a if ▽i ≥ 0,
▽i + 2∆b otherwise.
(1)
▶ Then, from the origin and on, we determine each movement based on
▽i: 






M1 if ▽i < 0,
M2 otherwise.
(2)
12 / 47
Bresenham’s Algorithm III
▶ We can calculate ▽i using the following simple recursive relation:
▽0 = 2∆b − ∆a,
▽i+1 =







▽i + 2∆b − 2∆a if ▽i ≥ 0,
▽i + 2∆b otherwise.
(1)
▶ Then, from the origin and on, we determine each movement based on
▽i: 






M1 if ▽i < 0,
M2 otherwise.
(2)
12 / 47
Next . . .
Background
Bresenham’s Line Drawing Algorithm
Review of Clock Skew Compensation Based on Extended Bresenham’s
Algorithm
Clock Skew Compensation with Optimal Error Bounds
Floating-Point Numbers
Bounds on The Initial Value of Skew-Compensated Clock
Numerical Examples
Conclusions
13 / 47
Hardware Clock Model
▶ We confine our discussions to a network with one head node and one
sensor node WLOG, where we describe the hardware clock T of the
sensor node with respect to the reference clock t of the head node
using the first-order affine clock model4
:
T(t) = (1 + ϵ) t + θ, (3)
where ϵ∈R and θ∈R denote the clock skew and offset, respectively;
(1 + ϵ)∈R+ in (3) is called clock frequency ratio in the literature.
▶ As we focus on the clock skew compensation, we simplify (3) by
setting θ to 0 and obtain
T(t) = (1 + ϵ) t. (4)
4
R. T. Rajan and A.-J. van der Veen, Proc. CAMSAP 2011, Dec. 2011, pp. 297–300.
14 / 47
Logical Clock Model
Compensating for the clock skew from the hardware clock T in (4), we can
obtain the logical clock t̂ of the sensor node—i.e., the estimation of the
reference clock t given the hardware clock T—as follows: For
ti<t≤ti+1 (i=0, 1, . . .),
t̂

T(t)

= t̂

T(ti)

+
T(t) − T(ti)
1 + ϵ̂i
, (5)
where ti is the reference time for the ith synchronization and ϵ̂i is the
estimated clock skew from the ith synchronization.5
5
The sensor node does not know the reference clock t as such but only the hardware
clock corresponding to t—i.e., T(t)—during the operation.
15 / 47
Theory vs. Reality
5 10 15 20 25 30 35 40 45 50
Number of Messages
10−15
10−14
10−13
10−12
10−11
10−10
10−9
MSE
RLS
CR
Joint MLE
GMLLE (Two-Way)
LB for CR
CRLB for Joint MLE
LB for GMLLE
MSE of the estimated clock skews.a
a
K. S. Kim, S. Lee, and E. G. Lim, IEEE
Trans. Commun., vol. 65, no. 1, pp. 347–359,
Jan. 2017.
0 200 400 600 800 1000 1200 1400 1600 1800
Time [s]
-1E-04
-5E-05
0E+00
5E-05
1E-04
Measurement
Time
Estimation
Error
[s]
EE-ASCFR
Measurement time estimation errors of EE-ASCFR.a
a
X. Huan and K. S. Kim, Comput. Netw.,
vol. 166, pp. 1–8, Jan. 2020.
16 / 47
Direct Application of Bresenham’s Algorithm
Δ
Δ
 1
̂
0,0 1 2 

1
2
− 1 + 1 
+ 1

∆
∆
−
− ( )
1 + ̂
17 / 47
Extension of Bresenham’s Algorithm I
Lemma (boundedness of ▽i)
▽i satisfies the following inequality:
|▽i|  2∆a. (6)
Definition (valid point set)
Given a destination point
(∆a, ∆b), we define a valid point
set V (∆a, ∆b) as a set of the points
on a valid path from (0, 0) to
(∆a, ∆b) according to Bresenham’s
algorithm.
(6,4)
0,0 1 2
1
2
3
4
3 4 5 6
All possible paths from the origin to a given destination point
based on M1 and M2 movements.
18 / 47
Extension of Bresenham’s Algorithm II
Definition (backward-reachable set)
Given a point (i, j)∈V (∆a, ∆b), we define a backward-reachable set B(i, j) as
a set of the points that can reach (i, j) by any combination of the movements
M1 and M2 as follows:
B(i, j) ≜

(k, l)|0≤ki, max(0, k−∆a+∆b)≤l≤ min(k, j) . (7)
Definition (extension of ▽i)
For a point (i, j)∈B(∆a, ∆b), we define ▽i(j) as follows:
▽i(j) ≜ 2(i∆b − j∆a). (8)
19 / 47
Extension of Bresenham’s Algorithm - III
Lemma (reachability of ▽i(j))
A point (i, j)∈V (∆a, ∆b) is reachable from any point (k, l)∈B(i, j) if we apply
Bresenham’s algorithm using ▽·(·) instead of ▽·.
20 / 47
Extension of Bresenham’s Algorithm - IV
Theorem (Clock Skew Compensation Based on Extended
Bresenham’s Algorithm)
Given the hardware clock i, we can obtain its skew-compensated clock j as follows:
Case 1. D
A
1: The skew-compensated clock j satisfies
i
D
A
− 1  j  i
D
A
+ 1. (9)
Unless iD
A
is an integer, there are two values satisfying (9). Due to the effect of
limited floating-point precision, however, we cannot know the exact value of iD
A
.
21 / 47
Extension of Bresenham’s Algorithm - IV
Theorem (Clock Skew Compensation Based on Extended
Bresenham’s Algorithm)
In this regard, (9) can be extended to include the effect of the precision loss:
i
D
A
− 1 − ε  j  i
D
A
+ 1 + ε, (10)
where ε(0) is the error due to the precision loss.
Let k, . . ., k+l be the candidate values of j satisfying (10). We determine j by
starting from the point (i−l, k) and applying Bresenham’s algorithm with ▽i−l(k)
and on; j is determined by the y coordinate of the valid point whose x coordinate is
i.
21 / 47
Extension of Bresenham’s Algorithm - IV
Theorem (Clock Skew Compensation Based on Extended
Bresenham’s Algorithm)
Case 2. D
A
1: In this case, we can decompose the skew-compensated clock j into
two components as follows:
j = i
D
A
= i + i
D − A
A
. (11)
Now that D−A
A
1, we can apply the same procedure of Case 1 to the second
component in (11) by setting ∆a and ∆b to A and D−A, respectively. Let ¯
j be the
result from the procedure. The skew-compensated clock j is given by i+ ¯
j as per (11).
21 / 47
Clock Skew Compensation Example
− 4 − 3
+ 1
− 2 − 1
+ 2
+ 3
+ 4
An example of common starting points reaching all possible candidate points for the case of ∆b
∆a ≤1.
22 / 47
̂
T
∆
∆
−
− ( )
1 + ̂
0,0
Eq. (8)
Clock skew compensation based on extended Bresenham’s algorithm.
23 / 47
Next . . .
Background
Bresenham’s Line Drawing Algorithm
Review of Clock Skew Compensation Based on Extended Bresenham’s
Algorithm
Clock Skew Compensation with Optimal Error Bounds
Floating-Point Numbers
Bounds on The Initial Value of Skew-Compensated Clock
Numerical Examples
Conclusions
24 / 47
Issues in The Clock Skew Compensation Based on
Extended Bresenham’s Algorithm
▶ The extended bounds on the value of skew-compensated clock, which
are closely related with the initial condition of the proposed algorithm,
include a term for floating-point operation error due to precision loss
(i.e., ε in (10)).
▶ The value of ε is not explicitly mentioned in the theorem but
approximately set for numerical examples based on the property of the
single-precision floating-point format as defined in the IEEE standard for
floating-point arithmetic (IEEE 754-2008) [1].
▶ We revisit the main theorem, therefore, and provide practical as well as
theoretical bounds based on a systematic analysis of the errors of
floating-point operations.
25 / 47
Next . . .
Background
Bresenham’s Line Drawing Algorithm
Review of Clock Skew Compensation Based on Extended Bresenham’s
Algorithm
Clock Skew Compensation with Optimal Error Bounds
Floating-Point Numbers
Bounds on The Initial Value of Skew-Compensated Clock
Numerical Examples
Conclusions 26 / 47
Floating-Point Numbers - Overview
▶ An associated set of floating point numbers F with a base β and a precision
p and no restriction on the exponent range is defined as follows:
F = {0} ∪
n
Mβe
M, e ∈ Z, βp−1
≤ |M|  βp
o
, (12)
where M is a normalized representation, i.e.,
M = ±1.d1d2 · · · dp−1 × βp−1
= ±

1 + d1β−1
+ · · · + dp−1β−(p−1)

× βp−1
.
▶ Let fl : R → F denote a round-to-nearest function satisfying
|t − fl(t)| = min
f∈F
t − f , t ∈ R. (13)
27 / 47
Floating-Point Numbers - Distribution on A Number Line
0 1 2 3 4 5 6 7
1/2
1/4
1/8 1
Normalized numbers when β=2, p=3, emin= − 1, emax=2.
28 / 47
Floating-Point Numbers - IEEE 754-2008 Standard I
Table: Basic binary floating-point formats.
Name
Common Significand Decimal Decimal Exponent Exponent
Emin Emax
Name Bits Digits E max Bits Bias
binary32 Single precision 24 7.22 38.23 8 27
−1=127 -126 +127
binary64 Double precision 53 15.95 307.95 11 210
−1=1023 -1022 +1023
binary128 Quadruple precision 113 34.02 4931.77 15 214
−1=16383 -16382 +16383
29 / 47
Floating-Point Numbers - IEEE 754-2008 Standard II
Single-precision floating-point format.6
Double-precision floating-point format.7
6
“Single-precision floating-point format,” Wikipedia: The Free Encyclopedia,
Wikimedia Foundation, Accessed: Jan. 24, 2023.
7
“Double-precision floating-point format,” Wikipedia: The Free Encyclopedia,
Wikimedia Foundation, Accessed: Jan. 24, 2023.
30 / 47
Relative Errors of Floating-Point Operations - I
Based on F and fl, we can define two relative errors for t∈R and t,0:
E1(t) ≜
|t − fl(t)|
|t|
(14)
E2(t) ≜
|t − fl(t)|
|fl(t)|
, (15)
where E1 and E2 are the errors relative to t and fl(t), respectively.
31 / 47
Relative Errors of Floating-Point Operations - II
Table: Optimal relative error bounds 8.
t bound on E1(t) bound on E2(t)
real number u
1+u
u
xy u
1+u
u
x/y







u − 2u2
if β = 2,
u
1+u
if β  2







u−2u2
1+u−2u2 if β = 2,
u if β  2
▶ x, y∈F.
▶ u=1
2
β1−p
is the unit roundoff associated with fl and F.
8
C.-P. Jeannerod and S. M. Rump, Mathematics of computation, vol. 87, no. 310, pp.
803–819, 2018.
32 / 47
Next . . .
Background
Bresenham’s Line Drawing Algorithm
Review of Clock Skew Compensation Based on Extended Bresenham’s
Algorithm
Clock Skew Compensation with Optimal Error Bounds
Floating-Point Numbers
Bounds on The Initial Value of Skew-Compensated Clock
Numerical Examples
Conclusions 33 / 47
Bounds on The Initial Value of Skew-Compensated Clock
Lemma
For t=x
y
z
, where x, y, z∈R with x, y≥0 and z0, fl(t) satisfies
1 − u + 2u2
(1 + u)2(1 + 2u)
t ≤ fl(t) ≤
(1 + 2u)3
(1 + u − 2u2
)
(1 + u)2
t. (16)
▶ Note that ε (≥0) in (10) of the main theorem indicates the error due to
the precision loss in computing iD
A
.
▶ The above lemma provides the optimal bounds on the initial value of
skew-compensated clock based on the floating-point operations of
non-negative real numbers.
34 / 47
Extension of The Main Theorem
Now (10) of the main theorem can be extended as follows:
$
1−u+2u2
(1+u)2(1+2u)
t
%
≤ j ≤

(1 + 2u)3
(1+u−2u2
)
(1+u)2
t
'
, (17)
where t=iD
A
and u=2−p
.
35 / 47
Loosening Bounds for Practical Implementation I
▶ Though (17) provides theoretically-guaranteed lower and upper bounds
on the initial value of skew-compensated clock j, obtaining the exact
values of bounds—i.e., the lhs and the rhs—could be a challenge,
especially at resource-constrained sensor nodes with limited
floating-point precision.
▶ For its practical implementation based on limited floating-point
precision, therefore, we can loosen the lhs and the rhs of (17) as follows:
$
1−u+2u2
(1+u)2(1+2u)
t
%
≤ j ≤

(1 + 2u)3
(1+u−2u2
)
(1+u)2
t
'
,
$
1−u
(1+2u)3
t
%
≤ j ≤
l
(1 + 2u)3
t
m
. (18)
36 / 47
Loosening Bounds for Practical Implementation II
▶ Note that the lhs and the rhs of (18) consist only of the elements of F,
i.e.,
1 − u = (2p
− 1) 2−p
∈ F,
1 + 2u =

2p−1
+ 1

21−p
∈ F,
which eliminates the rounding errors for those terms not belonging to
F in (17).
37 / 47
Next . . .
Background
Bresenham’s Line Drawing Algorithm
Review of Clock Skew Compensation Based on Extended Bresenham’s
Algorithm
Clock Skew Compensation with Optimal Error Bounds
Floating-Point Numbers
Bounds on The Initial Value of Skew-Compensated Clock
Numerical Examples
Conclusions
38 / 47
Experimental Settings
▶ We fix D to 1, 000, 000 and generate one million samples of A whose
clock skews are uniformly distributed in the range of
[−100 ppm, 100 ppm].
▶ For the clock skew compensation by single and double-precision
floating-point arithmetic, we round down the results to obtain integer
values.
▶ The calculated bounds are compared to those based on binary512
floating-point format providing 489 precision in bits, which serve as a
reference for the comparison.
39 / 47
Comparison of Bounds
Bounds i
∆LB*
∆UB†
Min. Max. Avg. Min. Max. Avg.
1e6 0 0 0 0 0 0
Theoretical bounds of (17) 1e7 0 0 0 0 0 0
based on double precision 1e8 0 0 0 0 0 0
1e9 0 0 0 0 0 0
1e6 0 0 0 0 0 0
Theoretical bounds of (17) 1e7 −1 0 −5.0115e−1 0 1 2.2325e−1
based on single precision 1e8 -18 0 −7.9666 0 6 1.7206
1e9 -125 0 −4.7102e1 0 104 3.6533e1
1e6 0 0 0 0 0 0
Practical bounds of (18) 1e7 0 2 1.0023 0 1 2.2325e−1
based on single precision 1e8 0 12 5.9980 0 6 2.9912
1e9 0 120 5.9890e1 0 60 2.9880e1
1e6 0 1 4.9696e−1 0 0 0
Approximate bounds of (11) of [2] 1e7 −2 1 −5.0346e−1 −2 1 −2.8513e−1
based on single precision with ε=10−7
i 1e8 -20 10 −5.0063 -20 10 −4.8369
1e9 -199 100 −4.9669e1 -199 100 −4.9645e1
*
∆LB = LBbinary512 − LB, where LBbinary512 is the lower bound of (17) based on binary512.
†
∆UB = UB − UBbinary512, where UBbinary512 is the upper bound of (17) based on binary512.
40 / 47
Comparison of Algorithms
Algorithm i
Compensation error*
# of iterations
Min. Max. Avg. Min. Max. Avg.
Single precision†
1e6 0 0 0 – – –
1e7 0 0 0 – – –
1e8 −4 1 −1.9842 – – –
1e9 -19 44 1.2502e1 – – –
1e6 −1 0 −4.9663e−1 1 2 1.5034
Clock skew compensation with 1e7 −1 0 −4.9668e−1 1 8 4.5232
practical bounds of (18) 1e8 −1 0 −5.0220e−1 1 72 3.6710e1
1e9 −1 0 −4.9734e−1 1 832 4.1872e2
1e6 −1 0 −4.9663e−1 2 2 2
Clock skew compensation with 1e7 −1 0 −4.9668e−1 3 4 3.0050
approximate bounds of (11) of [2] 1e8 −1 0 −5.0220e−1 21 22 2.1005e1
1e9 −1 0 −4.9734e−1 201 202 2.0101e2
*
With respect to ⌊iD
A
⌋ based on double precision.
†
⌊iD
A
⌋ based on single precision.
41 / 47
Discussions: Comparison of Bounds
▶ Double precision is enough for the calculation of the theoretical
bounds of (17), while the results for both theoretical bounds of (17) and
the approximate bounds of [2] based on single precision violate the
reference bounds of (17) based on binary512 due to the floating-point
precision loss.
▶ This implies that the correctness of the results of the clock skew
compensation based on the main theorem with the approximate bounds
cannot be theoretically guaranteed.
▶ The loose practical bounds of (18) based on single precision do not
violate the reference bounds in spite of the limited floating-point
precision.
▶ It turns out that the loosening of the bounds counteracts the effect of
limited floating-point precision on the calculation of (18).
42 / 47
Discussions: Comparison of Bounds
▶ Double precision is enough for the calculation of the theoretical
bounds of (17), while the results for both theoretical bounds of (17) and
the approximate bounds of [2] based on single precision violate the
reference bounds of (17) based on binary512 due to the floating-point
precision loss.
▶ This implies that the correctness of the results of the clock skew
compensation based on the main theorem with the approximate bounds
cannot be theoretically guaranteed.
▶ The loose practical bounds of (18) based on single precision do not
violate the reference bounds in spite of the limited floating-point
precision.
▶ It turns out that the loosening of the bounds counteracts the effect of
limited floating-point precision on the calculation of (18).
42 / 47
Discussions: Comparison of Bounds
▶ Double precision is enough for the calculation of the theoretical
bounds of (17), while the results for both theoretical bounds of (17) and
the approximate bounds of [2] based on single precision violate the
reference bounds of (17) based on binary512 due to the floating-point
precision loss.
▶ This implies that the correctness of the results of the clock skew
compensation based on the main theorem with the approximate bounds
cannot be theoretically guaranteed.
▶ The loose practical bounds of (18) based on single precision do not
violate the reference bounds in spite of the limited floating-point
precision.
▶ It turns out that the loosening of the bounds counteracts the effect of
limited floating-point precision on the calculation of (18).
42 / 47
Discussions: Comparison of Bounds
▶ Double precision is enough for the calculation of the theoretical
bounds of (17), while the results for both theoretical bounds of (17) and
the approximate bounds of [2] based on single precision violate the
reference bounds of (17) based on binary512 due to the floating-point
precision loss.
▶ This implies that the correctness of the results of the clock skew
compensation based on the main theorem with the approximate bounds
cannot be theoretically guaranteed.
▶ The loose practical bounds of (18) based on single precision do not
violate the reference bounds in spite of the limited floating-point
precision.
▶ It turns out that the loosening of the bounds counteracts the effect of
limited floating-point precision on the calculation of (18).
42 / 47
Discussions: Comparison of Algorithms
▶ For the randomly-generated one million samples of A, the clock skew
compensation algorithm of [2] with both approximate and practical
bounds provides exactly the same bounded compensation errors
compared to the unbounded errors for the single-precision algorithm.
▶ The numbers of iterations with the practical bounds are larger than
those with the approximate bounds for i≥1e7.
▶ This indicates that the approximate bounds of [2] could provide valid
initial conditions for the cases considered in these examples with less
numbers of iterations than those for the practical bounds of (18) but at
the expense of the lack of theoretical guarantee.
43 / 47
Discussions: Comparison of Algorithms
▶ For the randomly-generated one million samples of A, the clock skew
compensation algorithm of [2] with both approximate and practical
bounds provides exactly the same bounded compensation errors
compared to the unbounded errors for the single-precision algorithm.
▶ The numbers of iterations with the practical bounds are larger than
those with the approximate bounds for i≥1e7.
▶ This indicates that the approximate bounds of [2] could provide valid
initial conditions for the cases considered in these examples with less
numbers of iterations than those for the practical bounds of (18) but at
the expense of the lack of theoretical guarantee.
43 / 47
Discussions: Comparison of Algorithms
▶ For the randomly-generated one million samples of A, the clock skew
compensation algorithm of [2] with both approximate and practical
bounds provides exactly the same bounded compensation errors
compared to the unbounded errors for the single-precision algorithm.
▶ The numbers of iterations with the practical bounds are larger than
those with the approximate bounds for i≥1e7.
▶ This indicates that the approximate bounds of [2] could provide valid
initial conditions for the cases considered in these examples with less
numbers of iterations than those for the practical bounds of (18) but at
the expense of the lack of theoretical guarantee.
43 / 47
Next . . .
Background
Bresenham’s Line Drawing Algorithm
Review of Clock Skew Compensation Based on Extended Bresenham’s
Algorithm
Clock Skew Compensation with Optimal Error Bounds
Floating-Point Numbers
Bounds on The Initial Value of Skew-Compensated Clock
Numerical Examples
Conclusions
44 / 47
Conclusions
▶ Revisit the main theorem of [2] and derive theoretical and practical
bounds on the initial value of skew-compensated clock based on a
systematic analysis of the errors of floating-point operations.
▶ The theoretical bounds provide a reference framework for the analysis
and comparison of bounds on the initial value of skew-compensated
clock.
▶ The practical bounds could replace the approximate bounds suggested
in [2] as an implementation option for limited floating-point precision.
▶ Demonstrate through numerical examples that the proposed practical
bounds based on single-precision floating-point format do not violate
the theoretical bounds and thereby can guarantee the correctness of
the clock skew compensation even on resource-constrained computing
platforms like WSN/IoT sensor nodes.
45 / 47
Conclusions
▶ Revisit the main theorem of [2] and derive theoretical and practical
bounds on the initial value of skew-compensated clock based on a
systematic analysis of the errors of floating-point operations.
▶ The theoretical bounds provide a reference framework for the analysis
and comparison of bounds on the initial value of skew-compensated
clock.
▶ The practical bounds could replace the approximate bounds suggested
in [2] as an implementation option for limited floating-point precision.
▶ Demonstrate through numerical examples that the proposed practical
bounds based on single-precision floating-point format do not violate
the theoretical bounds and thereby can guarantee the correctness of
the clock skew compensation even on resource-constrained computing
platforms like WSN/IoT sensor nodes.
45 / 47
Conclusions
▶ Revisit the main theorem of [2] and derive theoretical and practical
bounds on the initial value of skew-compensated clock based on a
systematic analysis of the errors of floating-point operations.
▶ The theoretical bounds provide a reference framework for the analysis
and comparison of bounds on the initial value of skew-compensated
clock.
▶ The practical bounds could replace the approximate bounds suggested
in [2] as an implementation option for limited floating-point precision.
▶ Demonstrate through numerical examples that the proposed practical
bounds based on single-precision floating-point format do not violate
the theoretical bounds and thereby can guarantee the correctness of
the clock skew compensation even on resource-constrained computing
platforms like WSN/IoT sensor nodes.
45 / 47
Conclusions
▶ Revisit the main theorem of [2] and derive theoretical and practical
bounds on the initial value of skew-compensated clock based on a
systematic analysis of the errors of floating-point operations.
▶ The theoretical bounds provide a reference framework for the analysis
and comparison of bounds on the initial value of skew-compensated
clock.
▶ The practical bounds could replace the approximate bounds suggested
in [2] as an implementation option for limited floating-point precision.
▶ Demonstrate through numerical examples that the proposed practical
bounds based on single-precision floating-point format do not violate
the theoretical bounds and thereby can guarantee the correctness of
the clock skew compensation even on resource-constrained computing
platforms like WSN/IoT sensor nodes.
45 / 47
References
[1] IEEE Computer Society, IEEE Std 754™-2008, IEEE Standard for
floating-point arithmetic, Std., Aug. 2008.
[2] K. S. Kim and S. Kang, “Clock skew compensation algorithm immune
to floating-point precision loss,” IEEE Commun. Lett., vol. 26, no. 4, pp.
902–906, Apr. 2022.
[3] S. Kang and K. S. Kim, “Theoretical and practical bounds on the initial
value of skew-compensated clock for clock skew compensation
algorithm immune to floating-point precision loss,” ArXiv e-prints,
2022. [Online]. Available: https://arxiv.org/abs/2208.11520
46 / 47
Thanks for your attention!
If you have any question, please contact me at
Kyeongsoo.Kim@xjtlu.edu.cn.

More Related Content

PDF
Clock Skew Compensation Algorithm Immune to Floating-Point Precision Loss
PDF
Theoretical and Practical Bounds on the Initial Value of Skew-Compensated Cl...
PDF
CG08 - Bresenham’s Line Algorithm Data structure.pdf
PDF
Computer graphics 2
PPTX
Bresenham's line drawing algorithm
PPTX
Computer Graphics
PDF
Bresenhems line Genration derivation for Mtech
PPT
Lecture-4-Scan_Conversion_Bresenhams_Algorithm.ppt
Clock Skew Compensation Algorithm Immune to Floating-Point Precision Loss
Theoretical and Practical Bounds on the Initial Value of Skew-Compensated Cl...
CG08 - Bresenham’s Line Algorithm Data structure.pdf
Computer graphics 2
Bresenham's line drawing algorithm
Computer Graphics
Bresenhems line Genration derivation for Mtech
Lecture-4-Scan_Conversion_Bresenhams_Algorithm.ppt

Similar to Theoretical and Practical Bounds on the Initial Value of Skew-Compensated Clock for Clock Skew Compensation Algorithm Immune to Floating-Point Precision Loss (Extended Version) (20)

PPTX
Output Primitive and Brenshamas Line.pptx
DOCX
Dda algo notes
PPT
Lab lecture 2 bresenham
PPTX
Output primitives in Computer Graphics
PDF
Chapter 2 Computer graphics by Kushal Bhattarai
PPT
1 linedrawing
PPTX
lecture 1.pptx
DOCX
Computer graphics question for exam solved
PDF
Bresenham line-drawing-algorithm By S L Sonawane.pdf
PPTX
OUTPUT PRIMITIVES.pptx
PPTX
OUTPUT PRIMITIVES.pptx
PPTX
B. SC CSIT Computer Graphics Unit1.2 By Tekendra Nath Yogi
PPTX
Bresenham's line algorithm
PDF
module 1.pdf
PDF
Computer Graphics Unit 2
PPTX
Bresenham's line drawing algorithm
PPT
Bresenham circles and polygons derication
PPT
Bresenham circlesandpolygons
PDF
Unit-2 raster scan graphics,line,circle and polygon algorithms
PPT
computer_graphics_line_algorithm in Computer Graphics
Output Primitive and Brenshamas Line.pptx
Dda algo notes
Lab lecture 2 bresenham
Output primitives in Computer Graphics
Chapter 2 Computer graphics by Kushal Bhattarai
1 linedrawing
lecture 1.pptx
Computer graphics question for exam solved
Bresenham line-drawing-algorithm By S L Sonawane.pdf
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptx
B. SC CSIT Computer Graphics Unit1.2 By Tekendra Nath Yogi
Bresenham's line algorithm
module 1.pdf
Computer Graphics Unit 2
Bresenham's line drawing algorithm
Bresenham circles and polygons derication
Bresenham circlesandpolygons
Unit-2 raster scan graphics,line,circle and polygon algorithms
computer_graphics_line_algorithm in Computer Graphics
Ad

More from Xi'an Jiaotong-Liverpool University (16)

PDF
On the ethical challenges in the use of AI/ML for research in science and eng...
PDF
Decentralized Indoor Localization Framework Based on Real-Time-Trainable Mode...
PPTX
Exploiting unlabeled RSSI fingerprints in multi-building and multi-floor indo...
PPTX
On the multi-dimensional augmentation of fingerprint data for indoor localiza...
PDF
Energy-Efficient Time Synchronization in Wireless Sensor Networks
PDF
Atomic Scheduling of Appliance Energy Consumption in Residential Smart Grid
PDF
Energy-Efficient Time Synchronization Achieving Nanosecond Accuracy in Wirele...
PDF
Atomic Scheduling of Appliance Energy Consumption in Residential Smart Grid
PDF
Photonics21 – Next-Generation Optical Internet Access: Roadmap for Broadband ...
PDF
Data Networks: Next-Generation Optical Access toward 10 Gb/s Everywhere
PDF
A Research Framework for the Clean-Slate Design of Next-Generation Optical Ac...
PDF
On Next-Generation Metro and Access Networks
PDF
IEEE 802.11s Tutorial - Overview of the Amendment for Wireless Local Area Mes...
PDF
Next-Generation Optical Access Architecture
PDF
Next-Generation Optical Access Architecture
PDF
Past, Present, and Future of Fiber-To-The-Home Solutions
On the ethical challenges in the use of AI/ML for research in science and eng...
Decentralized Indoor Localization Framework Based on Real-Time-Trainable Mode...
Exploiting unlabeled RSSI fingerprints in multi-building and multi-floor indo...
On the multi-dimensional augmentation of fingerprint data for indoor localiza...
Energy-Efficient Time Synchronization in Wireless Sensor Networks
Atomic Scheduling of Appliance Energy Consumption in Residential Smart Grid
Energy-Efficient Time Synchronization Achieving Nanosecond Accuracy in Wirele...
Atomic Scheduling of Appliance Energy Consumption in Residential Smart Grid
Photonics21 – Next-Generation Optical Internet Access: Roadmap for Broadband ...
Data Networks: Next-Generation Optical Access toward 10 Gb/s Everywhere
A Research Framework for the Clean-Slate Design of Next-Generation Optical Ac...
On Next-Generation Metro and Access Networks
IEEE 802.11s Tutorial - Overview of the Amendment for Wireless Local Area Mes...
Next-Generation Optical Access Architecture
Next-Generation Optical Access Architecture
Past, Present, and Future of Fiber-To-The-Home Solutions
Ad

Recently uploaded (20)

PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Artificial Intelligence
PPTX
Lecture Notes Electrical Wiring System Components
PDF
Well-logging-methods_new................
PPTX
Sustainable Sites - Green Building Construction
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
PPT on Performance Review to get promotions
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
Geodesy 1.pptx...............................................
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Embodied AI: Ushering in the Next Era of Intelligent Systems
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
bas. eng. economics group 4 presentation 1.pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Artificial Intelligence
Lecture Notes Electrical Wiring System Components
Well-logging-methods_new................
Sustainable Sites - Green Building Construction
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
R24 SURVEYING LAB MANUAL for civil enggi
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPT on Performance Review to get promotions
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Geodesy 1.pptx...............................................
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...

Theoretical and Practical Bounds on the Initial Value of Skew-Compensated Clock for Clock Skew Compensation Algorithm Immune to Floating-Point Precision Loss (Extended Version)

  • 1. Theoretical and Practical Bounds on the Initial Value of Skew-Compensated Clock for Clock Skew Compensation Algorithm Immune to Floating-Point Precision Loss Kyeong Soo (Joseph) Kim (With Seungyeop Kang) School of Advanced Technology Xi’an Jiaotong-Liverpool University Department of Mathematics Chungnam National University January 25, 2023 1 / 47
  • 3. Outline Background Bresenham’s Line Drawing Algorithm Review of Clock Skew Compensation Based on Extended Bresenham’s Algorithm Clock Skew Compensation with Optimal Error Bounds Numerical Examples Conclusions 3 / 47
  • 4. Next . . . Background Bresenham’s Line Drawing Algorithm Review of Clock Skew Compensation Based on Extended Bresenham’s Algorithm Clock Skew Compensation with Optimal Error Bounds Floating-Point Numbers Bounds on The Initial Value of Skew-Compensated Clock Numerical Examples Conclusions 4 / 47
  • 5. Target Environment: WSN/IoT Nodes ▶ Measuring data and/or detect events with sensors and connected to a WSN/Internet only through wireless channels. ▶ Limited in processing and battery-powered. 5 / 47
  • 6. Target Environment: WSN/IoT Nodes ▶ Measuring data and/or detect events with sensors and connected to a WSN/Internet only through wireless channels. ▶ Limited in processing and battery-powered. 5 / 47
  • 7. Effect of Clock Skew on Time Synchronization Ideal Clock Faster Clock Slower Clock Local Time Reference Time Time Synchronization Error 6 / 47
  • 8. Next . . . Background Bresenham’s Line Drawing Algorithm Review of Clock Skew Compensation Based on Extended Bresenham’s Algorithm Clock Skew Compensation with Optimal Error Bounds Floating-Point Numbers Bounds on The Initial Value of Skew-Compensated Clock Numerical Examples Conclusions 7 / 47
  • 9. Raster vs. Vector Graphics1 1 “Vector graphics,” Wikipedia: The Free Encyclopedia, Wikimedia Foundation, Accessed: Aug. 1, 2022. 8 / 47
  • 10. Drawing A Straight Line Between Two Points2 2 “How to implement Bresenham’s algorithm as a system of equations?,” StackExchange, Accessed: Aug. 1, 2022. 9 / 47
  • 11. Bresenham’s Algorithm3 I ▶ An algorithm determining the points of a 2-dimensional raster to approximate a straight line between two points. ▶ Implementable using only integer addition, subtraction, and bit shifting. ▶ An example of incremental error algorithms using simple integer arithmetic to update an error term that determines if another quantity is incremented to avoid expensive division or multiplication operations. Calcomp 565 drum plotter (circa 1959). 3 J. E. Bresenham, IBM Systems Journal, vol. 4, no. 1 pp. 25–30, 1965. 10 / 47
  • 12. Bresenham’s Algorithm3 I ▶ An algorithm determining the points of a 2-dimensional raster to approximate a straight line between two points. ▶ Implementable using only integer addition, subtraction, and bit shifting. ▶ An example of incremental error algorithms using simple integer arithmetic to update an error term that determines if another quantity is incremented to avoid expensive division or multiplication operations. Calcomp 565 drum plotter (circa 1959). 3 J. E. Bresenham, IBM Systems Journal, vol. 4, no. 1 pp. 25–30, 1965. 10 / 47
  • 13. Bresenham’s Algorithm3 I ▶ An algorithm determining the points of a 2-dimensional raster to approximate a straight line between two points. ▶ Implementable using only integer addition, subtraction, and bit shifting. ▶ An example of incremental error algorithms using simple integer arithmetic to update an error term that determines if another quantity is incremented to avoid expensive division or multiplication operations. Calcomp 565 drum plotter (circa 1959). 3 J. E. Bresenham, IBM Systems Journal, vol. 4, no. 1 pp. 25–30, 1965. 10 / 47
  • 14. Bresenham’s Algorithm II Consider two points D1(x1, y1) and D2(x2, y2) in the first octant. ▶ In the new coordinate system obtained by translation of the origin to D1, the new coordinates of D2 are given by (∆a, ∆b)=(x2−x1, y2−y1). ▶ For the first octant, ∆a≥∆b≥0. ▶ Plotter movements are limited to M1 and M2 in this case. Possible plotter movements. Sequence of plotter movements in the first octant. 11 / 47
  • 15. Bresenham’s Algorithm II Consider two points D1(x1, y1) and D2(x2, y2) in the first octant. ▶ In the new coordinate system obtained by translation of the origin to D1, the new coordinates of D2 are given by (∆a, ∆b)=(x2−x1, y2−y1). ▶ For the first octant, ∆a≥∆b≥0. ▶ Plotter movements are limited to M1 and M2 in this case. Possible plotter movements. Sequence of plotter movements in the first octant. 11 / 47
  • 16. Bresenham’s Algorithm II Consider two points D1(x1, y1) and D2(x2, y2) in the first octant. ▶ In the new coordinate system obtained by translation of the origin to D1, the new coordinates of D2 are given by (∆a, ∆b)=(x2−x1, y2−y1). ▶ For the first octant, ∆a≥∆b≥0. ▶ Plotter movements are limited to M1 and M2 in this case. Possible plotter movements. Sequence of plotter movements in the first octant. 11 / 47
  • 17. Bresenham’s Algorithm II Consider two points D1(x1, y1) and D2(x2, y2) in the first octant. ▶ In the new coordinate system obtained by translation of the origin to D1, the new coordinates of D2 are given by (∆a, ∆b)=(x2−x1, y2−y1). ▶ For the first octant, ∆a≥∆b≥0. ▶ Plotter movements are limited to M1 and M2 in this case. Possible plotter movements. Sequence of plotter movements in the first octant. 11 / 47
  • 18. Bresenham’s Algorithm III ▶ We can calculate ▽i using the following simple recursive relation: ▽0 = 2∆b − ∆a, ▽i+1 =        ▽i + 2∆b − 2∆a if ▽i ≥ 0, ▽i + 2∆b otherwise. (1) ▶ Then, from the origin and on, we determine each movement based on ▽i:        M1 if ▽i < 0, M2 otherwise. (2) 12 / 47
  • 19. Bresenham’s Algorithm III ▶ We can calculate ▽i using the following simple recursive relation: ▽0 = 2∆b − ∆a, ▽i+1 =        ▽i + 2∆b − 2∆a if ▽i ≥ 0, ▽i + 2∆b otherwise. (1) ▶ Then, from the origin and on, we determine each movement based on ▽i:        M1 if ▽i < 0, M2 otherwise. (2) 12 / 47
  • 20. Next . . . Background Bresenham’s Line Drawing Algorithm Review of Clock Skew Compensation Based on Extended Bresenham’s Algorithm Clock Skew Compensation with Optimal Error Bounds Floating-Point Numbers Bounds on The Initial Value of Skew-Compensated Clock Numerical Examples Conclusions 13 / 47
  • 21. Hardware Clock Model ▶ We confine our discussions to a network with one head node and one sensor node WLOG, where we describe the hardware clock T of the sensor node with respect to the reference clock t of the head node using the first-order affine clock model4 : T(t) = (1 + ϵ) t + θ, (3) where ϵ∈R and θ∈R denote the clock skew and offset, respectively; (1 + ϵ)∈R+ in (3) is called clock frequency ratio in the literature. ▶ As we focus on the clock skew compensation, we simplify (3) by setting θ to 0 and obtain T(t) = (1 + ϵ) t. (4) 4 R. T. Rajan and A.-J. van der Veen, Proc. CAMSAP 2011, Dec. 2011, pp. 297–300. 14 / 47
  • 22. Logical Clock Model Compensating for the clock skew from the hardware clock T in (4), we can obtain the logical clock t̂ of the sensor node—i.e., the estimation of the reference clock t given the hardware clock T—as follows: For ti<t≤ti+1 (i=0, 1, . . .), t̂ T(t) = t̂ T(ti) + T(t) − T(ti) 1 + ϵ̂i , (5) where ti is the reference time for the ith synchronization and ϵ̂i is the estimated clock skew from the ith synchronization.5 5 The sensor node does not know the reference clock t as such but only the hardware clock corresponding to t—i.e., T(t)—during the operation. 15 / 47
  • 23. Theory vs. Reality 5 10 15 20 25 30 35 40 45 50 Number of Messages 10−15 10−14 10−13 10−12 10−11 10−10 10−9 MSE RLS CR Joint MLE GMLLE (Two-Way) LB for CR CRLB for Joint MLE LB for GMLLE MSE of the estimated clock skews.a a K. S. Kim, S. Lee, and E. G. Lim, IEEE Trans. Commun., vol. 65, no. 1, pp. 347–359, Jan. 2017. 0 200 400 600 800 1000 1200 1400 1600 1800 Time [s] -1E-04 -5E-05 0E+00 5E-05 1E-04 Measurement Time Estimation Error [s] EE-ASCFR Measurement time estimation errors of EE-ASCFR.a a X. Huan and K. S. Kim, Comput. Netw., vol. 166, pp. 1–8, Jan. 2020. 16 / 47
  • 24. Direct Application of Bresenham’s Algorithm Δ Δ 1 ̂ 0,0 1 2   1 2 − 1 + 1  + 1  ∆ ∆ − − ( ) 1 + ̂ 17 / 47
  • 25. Extension of Bresenham’s Algorithm I Lemma (boundedness of ▽i) ▽i satisfies the following inequality: |▽i| 2∆a. (6) Definition (valid point set) Given a destination point (∆a, ∆b), we define a valid point set V (∆a, ∆b) as a set of the points on a valid path from (0, 0) to (∆a, ∆b) according to Bresenham’s algorithm. (6,4) 0,0 1 2 1 2 3 4 3 4 5 6 All possible paths from the origin to a given destination point based on M1 and M2 movements. 18 / 47
  • 26. Extension of Bresenham’s Algorithm II Definition (backward-reachable set) Given a point (i, j)∈V (∆a, ∆b), we define a backward-reachable set B(i, j) as a set of the points that can reach (i, j) by any combination of the movements M1 and M2 as follows: B(i, j) ≜ (k, l)|0≤ki, max(0, k−∆a+∆b)≤l≤ min(k, j) . (7) Definition (extension of ▽i) For a point (i, j)∈B(∆a, ∆b), we define ▽i(j) as follows: ▽i(j) ≜ 2(i∆b − j∆a). (8) 19 / 47
  • 27. Extension of Bresenham’s Algorithm - III Lemma (reachability of ▽i(j)) A point (i, j)∈V (∆a, ∆b) is reachable from any point (k, l)∈B(i, j) if we apply Bresenham’s algorithm using ▽·(·) instead of ▽·. 20 / 47
  • 28. Extension of Bresenham’s Algorithm - IV Theorem (Clock Skew Compensation Based on Extended Bresenham’s Algorithm) Given the hardware clock i, we can obtain its skew-compensated clock j as follows: Case 1. D A 1: The skew-compensated clock j satisfies i D A − 1 j i D A + 1. (9) Unless iD A is an integer, there are two values satisfying (9). Due to the effect of limited floating-point precision, however, we cannot know the exact value of iD A . 21 / 47
  • 29. Extension of Bresenham’s Algorithm - IV Theorem (Clock Skew Compensation Based on Extended Bresenham’s Algorithm) In this regard, (9) can be extended to include the effect of the precision loss: i D A − 1 − ε j i D A + 1 + ε, (10) where ε(0) is the error due to the precision loss. Let k, . . ., k+l be the candidate values of j satisfying (10). We determine j by starting from the point (i−l, k) and applying Bresenham’s algorithm with ▽i−l(k) and on; j is determined by the y coordinate of the valid point whose x coordinate is i. 21 / 47
  • 30. Extension of Bresenham’s Algorithm - IV Theorem (Clock Skew Compensation Based on Extended Bresenham’s Algorithm) Case 2. D A 1: In this case, we can decompose the skew-compensated clock j into two components as follows: j = i D A = i + i D − A A . (11) Now that D−A A 1, we can apply the same procedure of Case 1 to the second component in (11) by setting ∆a and ∆b to A and D−A, respectively. Let ¯ j be the result from the procedure. The skew-compensated clock j is given by i+ ¯ j as per (11). 21 / 47
  • 31. Clock Skew Compensation Example − 4 − 3 + 1 − 2 − 1 + 2 + 3 + 4 An example of common starting points reaching all possible candidate points for the case of ∆b ∆a ≤1. 22 / 47
  • 32. ̂ T ∆ ∆ − − ( ) 1 + ̂ 0,0 Eq. (8) Clock skew compensation based on extended Bresenham’s algorithm. 23 / 47
  • 33. Next . . . Background Bresenham’s Line Drawing Algorithm Review of Clock Skew Compensation Based on Extended Bresenham’s Algorithm Clock Skew Compensation with Optimal Error Bounds Floating-Point Numbers Bounds on The Initial Value of Skew-Compensated Clock Numerical Examples Conclusions 24 / 47
  • 34. Issues in The Clock Skew Compensation Based on Extended Bresenham’s Algorithm ▶ The extended bounds on the value of skew-compensated clock, which are closely related with the initial condition of the proposed algorithm, include a term for floating-point operation error due to precision loss (i.e., ε in (10)). ▶ The value of ε is not explicitly mentioned in the theorem but approximately set for numerical examples based on the property of the single-precision floating-point format as defined in the IEEE standard for floating-point arithmetic (IEEE 754-2008) [1]. ▶ We revisit the main theorem, therefore, and provide practical as well as theoretical bounds based on a systematic analysis of the errors of floating-point operations. 25 / 47
  • 35. Next . . . Background Bresenham’s Line Drawing Algorithm Review of Clock Skew Compensation Based on Extended Bresenham’s Algorithm Clock Skew Compensation with Optimal Error Bounds Floating-Point Numbers Bounds on The Initial Value of Skew-Compensated Clock Numerical Examples Conclusions 26 / 47
  • 36. Floating-Point Numbers - Overview ▶ An associated set of floating point numbers F with a base β and a precision p and no restriction on the exponent range is defined as follows: F = {0} ∪ n Mβe M, e ∈ Z, βp−1 ≤ |M| βp o , (12) where M is a normalized representation, i.e., M = ±1.d1d2 · · · dp−1 × βp−1 = ± 1 + d1β−1 + · · · + dp−1β−(p−1) × βp−1 . ▶ Let fl : R → F denote a round-to-nearest function satisfying |t − fl(t)| = min f∈F t − f , t ∈ R. (13) 27 / 47
  • 37. Floating-Point Numbers - Distribution on A Number Line 0 1 2 3 4 5 6 7 1/2 1/4 1/8 1 Normalized numbers when β=2, p=3, emin= − 1, emax=2. 28 / 47
  • 38. Floating-Point Numbers - IEEE 754-2008 Standard I Table: Basic binary floating-point formats. Name Common Significand Decimal Decimal Exponent Exponent Emin Emax Name Bits Digits E max Bits Bias binary32 Single precision 24 7.22 38.23 8 27 −1=127 -126 +127 binary64 Double precision 53 15.95 307.95 11 210 −1=1023 -1022 +1023 binary128 Quadruple precision 113 34.02 4931.77 15 214 −1=16383 -16382 +16383 29 / 47
  • 39. Floating-Point Numbers - IEEE 754-2008 Standard II Single-precision floating-point format.6 Double-precision floating-point format.7 6 “Single-precision floating-point format,” Wikipedia: The Free Encyclopedia, Wikimedia Foundation, Accessed: Jan. 24, 2023. 7 “Double-precision floating-point format,” Wikipedia: The Free Encyclopedia, Wikimedia Foundation, Accessed: Jan. 24, 2023. 30 / 47
  • 40. Relative Errors of Floating-Point Operations - I Based on F and fl, we can define two relative errors for t∈R and t,0: E1(t) ≜ |t − fl(t)| |t| (14) E2(t) ≜ |t − fl(t)| |fl(t)| , (15) where E1 and E2 are the errors relative to t and fl(t), respectively. 31 / 47
  • 41. Relative Errors of Floating-Point Operations - II Table: Optimal relative error bounds 8. t bound on E1(t) bound on E2(t) real number u 1+u u xy u 1+u u x/y        u − 2u2 if β = 2, u 1+u if β 2        u−2u2 1+u−2u2 if β = 2, u if β 2 ▶ x, y∈F. ▶ u=1 2 β1−p is the unit roundoff associated with fl and F. 8 C.-P. Jeannerod and S. M. Rump, Mathematics of computation, vol. 87, no. 310, pp. 803–819, 2018. 32 / 47
  • 42. Next . . . Background Bresenham’s Line Drawing Algorithm Review of Clock Skew Compensation Based on Extended Bresenham’s Algorithm Clock Skew Compensation with Optimal Error Bounds Floating-Point Numbers Bounds on The Initial Value of Skew-Compensated Clock Numerical Examples Conclusions 33 / 47
  • 43. Bounds on The Initial Value of Skew-Compensated Clock Lemma For t=x y z , where x, y, z∈R with x, y≥0 and z0, fl(t) satisfies 1 − u + 2u2 (1 + u)2(1 + 2u) t ≤ fl(t) ≤ (1 + 2u)3 (1 + u − 2u2 ) (1 + u)2 t. (16) ▶ Note that ε (≥0) in (10) of the main theorem indicates the error due to the precision loss in computing iD A . ▶ The above lemma provides the optimal bounds on the initial value of skew-compensated clock based on the floating-point operations of non-negative real numbers. 34 / 47
  • 44. Extension of The Main Theorem Now (10) of the main theorem can be extended as follows: $ 1−u+2u2 (1+u)2(1+2u) t % ≤ j ≤ (1 + 2u)3 (1+u−2u2 ) (1+u)2 t ' , (17) where t=iD A and u=2−p . 35 / 47
  • 45. Loosening Bounds for Practical Implementation I ▶ Though (17) provides theoretically-guaranteed lower and upper bounds on the initial value of skew-compensated clock j, obtaining the exact values of bounds—i.e., the lhs and the rhs—could be a challenge, especially at resource-constrained sensor nodes with limited floating-point precision. ▶ For its practical implementation based on limited floating-point precision, therefore, we can loosen the lhs and the rhs of (17) as follows: $ 1−u+2u2 (1+u)2(1+2u) t % ≤ j ≤ (1 + 2u)3 (1+u−2u2 ) (1+u)2 t ' , $ 1−u (1+2u)3 t % ≤ j ≤ l (1 + 2u)3 t m . (18) 36 / 47
  • 46. Loosening Bounds for Practical Implementation II ▶ Note that the lhs and the rhs of (18) consist only of the elements of F, i.e., 1 − u = (2p − 1) 2−p ∈ F, 1 + 2u = 2p−1 + 1 21−p ∈ F, which eliminates the rounding errors for those terms not belonging to F in (17). 37 / 47
  • 47. Next . . . Background Bresenham’s Line Drawing Algorithm Review of Clock Skew Compensation Based on Extended Bresenham’s Algorithm Clock Skew Compensation with Optimal Error Bounds Floating-Point Numbers Bounds on The Initial Value of Skew-Compensated Clock Numerical Examples Conclusions 38 / 47
  • 48. Experimental Settings ▶ We fix D to 1, 000, 000 and generate one million samples of A whose clock skews are uniformly distributed in the range of [−100 ppm, 100 ppm]. ▶ For the clock skew compensation by single and double-precision floating-point arithmetic, we round down the results to obtain integer values. ▶ The calculated bounds are compared to those based on binary512 floating-point format providing 489 precision in bits, which serve as a reference for the comparison. 39 / 47
  • 49. Comparison of Bounds Bounds i ∆LB* ∆UB† Min. Max. Avg. Min. Max. Avg. 1e6 0 0 0 0 0 0 Theoretical bounds of (17) 1e7 0 0 0 0 0 0 based on double precision 1e8 0 0 0 0 0 0 1e9 0 0 0 0 0 0 1e6 0 0 0 0 0 0 Theoretical bounds of (17) 1e7 −1 0 −5.0115e−1 0 1 2.2325e−1 based on single precision 1e8 -18 0 −7.9666 0 6 1.7206 1e9 -125 0 −4.7102e1 0 104 3.6533e1 1e6 0 0 0 0 0 0 Practical bounds of (18) 1e7 0 2 1.0023 0 1 2.2325e−1 based on single precision 1e8 0 12 5.9980 0 6 2.9912 1e9 0 120 5.9890e1 0 60 2.9880e1 1e6 0 1 4.9696e−1 0 0 0 Approximate bounds of (11) of [2] 1e7 −2 1 −5.0346e−1 −2 1 −2.8513e−1 based on single precision with ε=10−7 i 1e8 -20 10 −5.0063 -20 10 −4.8369 1e9 -199 100 −4.9669e1 -199 100 −4.9645e1 * ∆LB = LBbinary512 − LB, where LBbinary512 is the lower bound of (17) based on binary512. † ∆UB = UB − UBbinary512, where UBbinary512 is the upper bound of (17) based on binary512. 40 / 47
  • 50. Comparison of Algorithms Algorithm i Compensation error* # of iterations Min. Max. Avg. Min. Max. Avg. Single precision† 1e6 0 0 0 – – – 1e7 0 0 0 – – – 1e8 −4 1 −1.9842 – – – 1e9 -19 44 1.2502e1 – – – 1e6 −1 0 −4.9663e−1 1 2 1.5034 Clock skew compensation with 1e7 −1 0 −4.9668e−1 1 8 4.5232 practical bounds of (18) 1e8 −1 0 −5.0220e−1 1 72 3.6710e1 1e9 −1 0 −4.9734e−1 1 832 4.1872e2 1e6 −1 0 −4.9663e−1 2 2 2 Clock skew compensation with 1e7 −1 0 −4.9668e−1 3 4 3.0050 approximate bounds of (11) of [2] 1e8 −1 0 −5.0220e−1 21 22 2.1005e1 1e9 −1 0 −4.9734e−1 201 202 2.0101e2 * With respect to ⌊iD A ⌋ based on double precision. † ⌊iD A ⌋ based on single precision. 41 / 47
  • 51. Discussions: Comparison of Bounds ▶ Double precision is enough for the calculation of the theoretical bounds of (17), while the results for both theoretical bounds of (17) and the approximate bounds of [2] based on single precision violate the reference bounds of (17) based on binary512 due to the floating-point precision loss. ▶ This implies that the correctness of the results of the clock skew compensation based on the main theorem with the approximate bounds cannot be theoretically guaranteed. ▶ The loose practical bounds of (18) based on single precision do not violate the reference bounds in spite of the limited floating-point precision. ▶ It turns out that the loosening of the bounds counteracts the effect of limited floating-point precision on the calculation of (18). 42 / 47
  • 52. Discussions: Comparison of Bounds ▶ Double precision is enough for the calculation of the theoretical bounds of (17), while the results for both theoretical bounds of (17) and the approximate bounds of [2] based on single precision violate the reference bounds of (17) based on binary512 due to the floating-point precision loss. ▶ This implies that the correctness of the results of the clock skew compensation based on the main theorem with the approximate bounds cannot be theoretically guaranteed. ▶ The loose practical bounds of (18) based on single precision do not violate the reference bounds in spite of the limited floating-point precision. ▶ It turns out that the loosening of the bounds counteracts the effect of limited floating-point precision on the calculation of (18). 42 / 47
  • 53. Discussions: Comparison of Bounds ▶ Double precision is enough for the calculation of the theoretical bounds of (17), while the results for both theoretical bounds of (17) and the approximate bounds of [2] based on single precision violate the reference bounds of (17) based on binary512 due to the floating-point precision loss. ▶ This implies that the correctness of the results of the clock skew compensation based on the main theorem with the approximate bounds cannot be theoretically guaranteed. ▶ The loose practical bounds of (18) based on single precision do not violate the reference bounds in spite of the limited floating-point precision. ▶ It turns out that the loosening of the bounds counteracts the effect of limited floating-point precision on the calculation of (18). 42 / 47
  • 54. Discussions: Comparison of Bounds ▶ Double precision is enough for the calculation of the theoretical bounds of (17), while the results for both theoretical bounds of (17) and the approximate bounds of [2] based on single precision violate the reference bounds of (17) based on binary512 due to the floating-point precision loss. ▶ This implies that the correctness of the results of the clock skew compensation based on the main theorem with the approximate bounds cannot be theoretically guaranteed. ▶ The loose practical bounds of (18) based on single precision do not violate the reference bounds in spite of the limited floating-point precision. ▶ It turns out that the loosening of the bounds counteracts the effect of limited floating-point precision on the calculation of (18). 42 / 47
  • 55. Discussions: Comparison of Algorithms ▶ For the randomly-generated one million samples of A, the clock skew compensation algorithm of [2] with both approximate and practical bounds provides exactly the same bounded compensation errors compared to the unbounded errors for the single-precision algorithm. ▶ The numbers of iterations with the practical bounds are larger than those with the approximate bounds for i≥1e7. ▶ This indicates that the approximate bounds of [2] could provide valid initial conditions for the cases considered in these examples with less numbers of iterations than those for the practical bounds of (18) but at the expense of the lack of theoretical guarantee. 43 / 47
  • 56. Discussions: Comparison of Algorithms ▶ For the randomly-generated one million samples of A, the clock skew compensation algorithm of [2] with both approximate and practical bounds provides exactly the same bounded compensation errors compared to the unbounded errors for the single-precision algorithm. ▶ The numbers of iterations with the practical bounds are larger than those with the approximate bounds for i≥1e7. ▶ This indicates that the approximate bounds of [2] could provide valid initial conditions for the cases considered in these examples with less numbers of iterations than those for the practical bounds of (18) but at the expense of the lack of theoretical guarantee. 43 / 47
  • 57. Discussions: Comparison of Algorithms ▶ For the randomly-generated one million samples of A, the clock skew compensation algorithm of [2] with both approximate and practical bounds provides exactly the same bounded compensation errors compared to the unbounded errors for the single-precision algorithm. ▶ The numbers of iterations with the practical bounds are larger than those with the approximate bounds for i≥1e7. ▶ This indicates that the approximate bounds of [2] could provide valid initial conditions for the cases considered in these examples with less numbers of iterations than those for the practical bounds of (18) but at the expense of the lack of theoretical guarantee. 43 / 47
  • 58. Next . . . Background Bresenham’s Line Drawing Algorithm Review of Clock Skew Compensation Based on Extended Bresenham’s Algorithm Clock Skew Compensation with Optimal Error Bounds Floating-Point Numbers Bounds on The Initial Value of Skew-Compensated Clock Numerical Examples Conclusions 44 / 47
  • 59. Conclusions ▶ Revisit the main theorem of [2] and derive theoretical and practical bounds on the initial value of skew-compensated clock based on a systematic analysis of the errors of floating-point operations. ▶ The theoretical bounds provide a reference framework for the analysis and comparison of bounds on the initial value of skew-compensated clock. ▶ The practical bounds could replace the approximate bounds suggested in [2] as an implementation option for limited floating-point precision. ▶ Demonstrate through numerical examples that the proposed practical bounds based on single-precision floating-point format do not violate the theoretical bounds and thereby can guarantee the correctness of the clock skew compensation even on resource-constrained computing platforms like WSN/IoT sensor nodes. 45 / 47
  • 60. Conclusions ▶ Revisit the main theorem of [2] and derive theoretical and practical bounds on the initial value of skew-compensated clock based on a systematic analysis of the errors of floating-point operations. ▶ The theoretical bounds provide a reference framework for the analysis and comparison of bounds on the initial value of skew-compensated clock. ▶ The practical bounds could replace the approximate bounds suggested in [2] as an implementation option for limited floating-point precision. ▶ Demonstrate through numerical examples that the proposed practical bounds based on single-precision floating-point format do not violate the theoretical bounds and thereby can guarantee the correctness of the clock skew compensation even on resource-constrained computing platforms like WSN/IoT sensor nodes. 45 / 47
  • 61. Conclusions ▶ Revisit the main theorem of [2] and derive theoretical and practical bounds on the initial value of skew-compensated clock based on a systematic analysis of the errors of floating-point operations. ▶ The theoretical bounds provide a reference framework for the analysis and comparison of bounds on the initial value of skew-compensated clock. ▶ The practical bounds could replace the approximate bounds suggested in [2] as an implementation option for limited floating-point precision. ▶ Demonstrate through numerical examples that the proposed practical bounds based on single-precision floating-point format do not violate the theoretical bounds and thereby can guarantee the correctness of the clock skew compensation even on resource-constrained computing platforms like WSN/IoT sensor nodes. 45 / 47
  • 62. Conclusions ▶ Revisit the main theorem of [2] and derive theoretical and practical bounds on the initial value of skew-compensated clock based on a systematic analysis of the errors of floating-point operations. ▶ The theoretical bounds provide a reference framework for the analysis and comparison of bounds on the initial value of skew-compensated clock. ▶ The practical bounds could replace the approximate bounds suggested in [2] as an implementation option for limited floating-point precision. ▶ Demonstrate through numerical examples that the proposed practical bounds based on single-precision floating-point format do not violate the theoretical bounds and thereby can guarantee the correctness of the clock skew compensation even on resource-constrained computing platforms like WSN/IoT sensor nodes. 45 / 47
  • 63. References [1] IEEE Computer Society, IEEE Std 754™-2008, IEEE Standard for floating-point arithmetic, Std., Aug. 2008. [2] K. S. Kim and S. Kang, “Clock skew compensation algorithm immune to floating-point precision loss,” IEEE Commun. Lett., vol. 26, no. 4, pp. 902–906, Apr. 2022. [3] S. Kang and K. S. Kim, “Theoretical and practical bounds on the initial value of skew-compensated clock for clock skew compensation algorithm immune to floating-point precision loss,” ArXiv e-prints, 2022. [Online]. Available: https://arxiv.org/abs/2208.11520 46 / 47
  • 64. Thanks for your attention! If you have any question, please contact me at Kyeongsoo.Kim@xjtlu.edu.cn.