You are on page 1of 20

Trigonometric Interpolation and Approximation Theory

21010307
Department of Mathematics and Statistics
University of Reading
March 2, 2016

Abstract
This research project considers the topic of Trigonometric Interpolation and Approximation Theory and the following report acts as a documentation of key theories
and techniques in this field, drawing from various sources as a reference. To begin, interpolation theory is introduced and a brief discussion is given on how it can be applied
to trigonometric functions, before moving on to define a trigonometric polynomial as
a sum of sine and cosine functions. An important technique to interpolate any given
data set is developed and an example is shown to prove its effectiveness. Following this
an introduction to approximation theory is given, discussing the importance of orthogonality in best approximation and the use of the Fourier series to express any periodic
function as a trigonometric polynomial. Two examples are considered in the continuous
case and extensive analysis of the approximation accuracy is undertaken. The findings
of said analysis show that as the degree of approximating polynomial increases, the
error in approximation decreases. As such, given any periodic function we are able to
approximate it to a high degree of accuracy using a higher order Fourier series. In
the discrete case, a lone example is considered but the extendability of the theory is
explained and expressed. The MATLAB code used to calculate the coefficients and
plot the approximating polynomials is given so that the reader is able to compute their
own examples and increase their understanding of the topic. Finally, at the conclusion
of this report the overall findings are presented and the most effective techniques are
outlined.

Part 3 Project (Project Report)

21010307

Contents
List of Tables

ii

List of Figures

iii

1 Introduction to Interpolation

2 Trigonometric Interpolation

2.1

Interpolating Data Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.2

Forming a Trigonometric Interpolant . . . . . . . . . . . . . . . . . . . . . .

3 Trigonometric Approximation Theory

3.1

Orthogonal Trigonometric Polynomials . . . . . . . . . . . . . . . . . . . . .

3.2

Fourier Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3.3

Continuous Least Squares Approximation . . . . . . . . . . . . . . . . . . .

Approximation of f (t) = | sin t| using Fourier Trigonometric Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Approximation of f (t) = t2 using Fourier Trigonometric Polynomials

Discrete Least Squares Approximation . . . . . . . . . . . . . . . . . . . . .

10

Approximation of f (t) = t2 + cos 2t using Discrete Least Squares


Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11

3.3.1
3.3.2
3.4

3.4.1

4 Conclusion

13

5 MATLAB Source Code

13

5.1

Source Code to Compute the Lagrange Interpolant . . . . . . . . . . . . . .

13

5.2

Source Code for Sections (3.3.1) and (3.3.2) . . . . . . . . . . . . . . . . . .

14

5.3

Source Code for Section (3.4.1) . . . . . . . . . . . . . . . . . . . . . . . . .

15

6 Bibliography

17

List of Tables
1
2

MA3PR

A table of the computed maximum absolute error values || sin(t)| pn (t)| in


the interval [, ] for each approximation. . . . . . . . . . . . . . . . . . .

A table of the computed maximum absolute error values |t2 pn (t)| in the
interval [, ] for each interpolant. . . . . . . . . . . . . . . . . . . . . . .

10

ii

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

21010307


A table of the computed maximum absolute error values | t2 + cos 2t pn (t)|
in the interval [, ] for approximating polynomials of degree 2 and 3. . .

12

List of Figures
1

Example of a cubic interpolating polynomial approximating sin(t). . . . . .

A plot of the data set {1, 2, 4, 5} as blue points and the interpolating
trigonometric polynomial of degree 2 in green. . . . . . . . . . . . . . . . . .

A plot of the function f (t) = | sin t| and the approximating trigonometric


polynomials p2 (t), p4 (t), p6 (t), p8 (t), p10 (t). . . . . . . . . . . . . . . . . . .

3
4
5

MA3PR

t2

A plot of the function f (t) = and the approximating trigonometric polynomials p2 (t), p4 (t), p6 (t), p8 (t), p10 (t). . . . . . . . . . . . . . . . . . . . . .

A plot of the function f (t) = t2 + cos 2t and the approximating discrete least
squares trigonometric polynomials p2 (t) and p3 (t). . . . . . . . . . . . . . .

12

iii

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

21010307

Introduction to Interpolation

Interpolation is an important concept within the field of Numerical Analysis. Suppose


we have a function f (x) and we want to to compute an approximation that is equal to
f (x) at a finite set of points {x0 , x1 , . . . , xn }. This is known as interpolation and it has
provided extremely useful applications for many branches of mathematics. We can also use
interpolation when a function may only be known at certain discrete points and we wish
to reconstruct it by computing an approximation that is equal to the unknown function
at these discrete points (see Chapter 8 of Burden and Faires (1993)). Interpolation is
done by approximating the required function using simpler functions such as polynomials.
Given (n + 1) critical points, a interpolated polynomial approximation is able to generate
an nth degree polynomial passing through these (n + 1) points. For example, given three
critical points the interpolating polynomial will be a quadratic function. More accurate
interpolation methods include Chebyshev, Legendre and Hermite polynomials but these
techniques fall outside the scope of this project.
Figure 1 below shows a polynomial of degree 3 approximating sin t on the interval [0, 2].
The blue plot shows the graph of y = sin t and the green plot shows the interpolating
polynomial. The interpolating function has been constructed using a 4-point Lagrange
interpolant (see Chapter 8.1 of Quarteroni (2000)).
Figure 1: Example of a cubic interpolating polynomial approximating sin(t).
1.5
Function
Interpolant

0.5

-0.5

-1

-1.5
0

As such, there are many methods in which to interpolate functions; with some techniques
providing better results on a particular set of functions. One such technique is that of
Trigonometric Interpolation which is best applied when interpolating periodic functions
such as sin t. This field of interpolation forms part of the subject of this report and is
discussed in detail in the following sections.

MA3PR

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

21010307

Trigonometric Interpolation

An extension of the theory of interpolation, known as Trigonometric Interpolation, focuses


primarily on approximating periodic functions. Such functions have the following property:
f (t + T ) = f (t),

t R,

(2.0.1)

for some T > 0. Since we have defined a periodic function we can now see that, for sin t,
we have
sin(t + 2) = sin t, t R.
(2.0.2)
Note that in the majority of cases polynomial interpolation is not relevant for periodic
functions since algebraic polynomials are not periodic (see Chapter 8 of Kress (1998)).
Thus instead we consider interpolating using trigonometric polynomials.
Let n R, then we can define a trigonometric polynomial of degree n as
Pn (t) =

n
X

ak cos kt +

k=0

n
X

bk sin kt,

(2.0.3)

k=1

where (a0 , a1 , . . . , an ) and (b1 , . . . , bn ) are real (or complex) coefficients. In other words, we
can interpolate a periodic function at any number of points using a sum of sine and cosine
functions. It is worth noting that we can also write our definition in the complex form as
follows:
n
X
Pn (t) =
k eikt ,
(2.0.4)
k=n

where we have used Eulers formula, which is defined as


eit = cos t + i sin t.

(2.0.5)

Some trigonometric calculations are made simpler using the notation given in (2.0.4) than
in (2.0.3). The polynomials that are defined in (2.0.3) are periodic with period 2 and
hence the interpolation nodes that are chosen are often from an interval of length 2, for
example
0 t0 < t1 < . . . < t2n 2.
(2.0.6)
In which case we often use equally spaced nodes given as (see Chapter 3.2 of Atkinson
(2005)),
2i
ti =
, i = 0, 1, . . . , 2n.
(2.0.7)
2n + 1
Now we can form the fundamental problem of trigonometric interpolation. We wish to find
a trigonometric polynomial pn (t) of degree n, such that,
pn (ti ) = f (ti ), i = 0, 1, . . . , 2n,

(2.0.8)

for given points {fj | 0 j 2n}, where f is the function we wish to interpolate.

MA3PR

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

2.1

21010307

Interpolating Data Sets

When considering interpolating a periodic function using trigonometric polynomials, we


almost always use an evenly spaced interval of the independent variable (here we use t). The
data set with n data points is given as {y0 , y1 , y2 , . . . , yn1 } but more accurately represents
the following data set:
 





4
2(n 1)
2
.
(2.1.1)
, y1 ,
, y2 , . . . ,
, yn1
(0, y0 ) ,
n
n
n
For the data set given above the degree of the interpolating polynomial depends on whether
the number of data points, n, is even or odd. If m is the degree of the trigonometric
interpolant, then the relation between m and n is such that
n1
,
2
n
n even = n = 2m = m = .
2

n odd = n = 2m + 1 = m =

(2.1.2)
(2.1.3)

For example the data set {1, 3, 2, 5} has n = 4 elements and thus induces an interpolating
polynomial of degree m = n2 = 2. Because there is a distinction between odd and even data
sets the interpolating polynomials have two forms. If n is odd we have,
f (t) =

a0
+ a1 cos t + . . . + am cos mt + b1 sin t + . . . + bm sin mt,
2

(2.1.4)

and if n is even we have (notice the am term),


f (t) =

a0
am
+ a1 cos t + . . . +
cos mt + b1 sin t + . . . + bm sin mt.
2
2

(2.1.5)

In both instances, the coefficients are given by,


n1

ak =

2X
yi cos
n

2
bk =
n

i=0
n1
X


yi sin

i=0

2ik
n

2ik
n

(2.1.6)

(2.1.7)

Now we can form a trigonometric interpolating polynomial for any given data set - a very
useful skill! The following section shows a particular example of how to construct such an
interpolant.

2.2

Forming a Trigonometric Interpolant

Consider the data set given by {1, 2, 4, 5}. We have n = 4 data points which means the
interpolating polynomial will be of degree m = n2 = 2. Now all that is left to do is to

MA3PR

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

21010307

compute the coefficients a0 , a1 , a2 , b1 and b2 using the formulas in (2.1.6) and (2.1.7).
a0 =
a1 =
a2 =
b1 =
b2 =

1
1
(1. cos(0) + 2. cos(0) 4. cos(0) + 5. cos(0)) = (1 + 2 4 + 5) = 2,
2
 2
 
1
1
3
5
1. cos(0) + 2. cos
= (1 + 0 + 4 + 0) = ,
4. cos() + 5. cos
2
2
2
2
2
1
1
(1. cos(0) + 2. cos () 4. cos(2) + 5. cos (3)) = (1 2 4 5) = 5,
2
  2
 
1
3
1
3
1. sin(0) + 2. sin
= (0 + 2 + 0 5) = ,
4. sin() + 5. sin
2
2
2
2
2
1
1
(1. sin(0) + 2. sin () 4. sin(2) + 5. sin (3)) = (0 + 0 0 + 0) = 0.
2
2

Hence the trigonometric interpolant of degree 2 that interpolates the data set {1, 2, 4, 5}
is,
a0
a2
f (t)
+ a1 cos t +
cos 2t + b1 sin t + b2 sin 2t
2
2
5
3
5
= 1 + cos t cos 2t sin t.
2
2
2
Figure 2: A plot of the data set {1, 2, 4, 5} as blue points and the interpolating trigonometric polynomial of degree 2 in green.
6

-2

-4

-6
0

/2

3/2

As one can see, the interpolant passes through each of the data points defined in our data
set. Thus we have defined a powerful trigonometric curve fitting tool to interpolate a set
of data. Note that this method can also be used to interpolate function data. For instance
if we wanted to interpolate the function f (t) = t2 we could calculate the function values at
several key points and use those values as our data set.
MA3PR

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

21010307

Trigonometric Approximation Theory

Approximation Theory is a closely related topic to interpolation which focuses on how


functions can be best approximated using simpler functions. The aim here is to find an
approximation that is as close to the original function as we can, which can be done by
using a high degree approximating polynomial or by limiting the approximation interval.

3.1

Orthogonal Trigonometric Polynomials

The first thing to consider when constructing a best approximation are orthogonal systems
of trigonometric polynomials. We begin by noting that we can rewrite the product of sine
and cosine functions as sums using trigonometric identities as follows,

1
cos(t1 t2 ) cos(t1 + t2 ) ,
(3.1.1)
sin t1 sin t2 =
2

1
cos(t1 t2 ) + cos(t1 + t2 ) ,
(3.1.2)
cos t1 cos t2 =
2

1
sin t1 cos t2 =
sin(t1 t2 ) + sin(t1 + t2 ) .
(3.1.3)
2
Theorem 3.1. Let n, k R, then we have the mutual orthogonality properties given by,
(




Z l
l if k = n
nt
kt
cos
cos
dt =
(3.1.4)
l
l
0 if k 6= n
l
(




Z l
l if k = n
kt
nt
sin
dt =
(3.1.5)
sin
l
l
0 if k 6= n
l




Z l
nt
kt
cos
sin
dt = 0 n, k R
(3.1.6)
l
l
l
Proof. Proof of this is done by direct elementary integration of each case and is left as an
exercise to the reader.


Theorem 3.2. Given a positive integer n, the set of functions 0 , 1 , . . . , 2n1 where,

0 (t) = 2 ,
k (t) = cos kt,

n+k (t) = sin kt,

(3.1.7)

k = 1, . . . , n,

k = 1, . . . , n 1.

is an orthogonal set on the interval [, ] with reference to the weight function w(t) 1
(as shown in Chapter 8.5 of Burden and Faires (1993)).
Proof. The proof of this statement follows from the fact that the integrals over the interval
[, ] of cos kt and sin kt are zero, for any k R, and the integral of the product of cos
and sin is also zero due to the mutual orthogonality shown in (3.1.6).
These facts help us to develop an understanding of the properties of trigonometric functions
and how we can manipulate them to form an best approximation. Since we have now formed
an orthogonal system we can extend the theory some more.
MA3PR

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

3.2

21010307

Fourier Series

Here we recall the properties of the Fourier series and describe how this can be applied to
trigonometric approximation theory. We begin by defining the Fourier series of a function
f (t) on the interval [l, l] as





kt
kt
a0 X
ak cos
+ bk sin
.
(3.2.1)
f (t) =
+
2
l
l
kN

where (a0 , ak , bk ) are Fourier coefficients that we wish to find. Using intuition the reader can
see that the form of the Fourier series is extremely similar to the trigonometric polynomials
defined in (2.0.3) if defined on the interval [, ].
Theorem 3.3. Assume that f (t) has a Fourier series defined on the interval [l, l],
Z
1 l
f (t) dt,
a0 =
l l


Z
1 l
kt
ak =
f (t) cos
dt,
l l
l


Z
1 l
kt
bk =
f (t) sin
dt.
l l
l

then
(3.2.2)
(3.2.3)
(3.2.4)

Proof. We have





a0 X
kt
kt
f (t) =
+
ak cos
+ bk sin
,
2
l
l
kN


nt
and hence multiplying both sides by cos
yields
l








Z l
Z l
Z l
X
nt
a0
nt
kt
nt
f (t) cos
dt =
cos
dt +
cos
dt
ak
cos
l
l
l
l
l
l 2
l
kN


 !

Z l
kt
nt
+ bk
cos
sin
dt .
l
l
l


Therefore we have, using the mutual orthogonality of the sine and cosine functions proved
in Theorem (3.1),
Z l
Z l
X
a0
n = 0 =
f (t) dt =
dt +
(ak 0 + bk 0)
l
l 2
kN

= la0 .
and
Z

n = k =


f (t) cos

kt
l

a0
dt =
0 + ak
2

cos
l

kt
l


dt +

(bk 0)

kN

= lak .
Thus the result for a0 and ak follows. The proof of the formula for bk can be found using a


nt
similar approach but instead multiplying both sides by sin
.
l
MA3PR

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

21010307

Now that we have defined the coefficients of a Fourier trigonometric polynomial we can
now further explore their properties to see if they provide a useful way to best approximate
continuous periodic functions.

3.3

Continuous Least Squares Approximation

Let Tn be the set containing all the linear combinations of the functions defined in (3.1.7).
In this chapter we consider approximating functions that are continuous on the interval
[, ]. For a function f C[, ], we are tasked with finding the continuous least
squares approximation in Tn defined by
n


a0 X 
+
ak cos kt + bk sin kt .
(3.3.1)
2
k=1


Since from (3.1.7) we have that the set of functions 0 , 1 , . . . , 2n1 are orthogonal in
the interval [, ] with weight function w(t) 1, it follows that the coefficients that we
wish to find are given by,
R
Z
1
f (t) cos kt dt
=
f (t) cos kt dt, k = 0, 1, 2, . . . , n,
(3.3.2)
ak = R
2

(cos kt) dt
R
Z
1
f (t) sin kt dt
=
bk = R
f (t) sin kt dt, k = 0, 1, 2, . . . , n.
(3.3.3)
2

(sin kt) dt
Pn (t) =

In other words we can best approximate a continuous periodic function using a Fourier
trigonometric polynomial. What follows in this section is a series of examples which examine
the accuracy of this approximation technique.
3.3.1

Approximation of f (t) = | sin t| using Fourier Trigonometric Polynomials

The task in this example is to extract the trigonometric polynomial from the set Tn which
best approximates f (t) = | sin t| in the interval [, ]. The first objective is to determine
the coefficients a0 , ak and bk . Since | sin t| is an even function it follows that bk = 0. Hence
now we can use the formulas defined in (3.2.2) and (3.3.2) such that
Z
Z
1
2
4
a0 =
| sin t| dt =
sin t dt = ,

0

and

1
ak =

2
| sin t| cos kt dt =

sin t cos kt dt.


0

Note that 2 sin t cos kt = sin[(k + 1)t] sin[(k 1)t]. So for k 2 (note a1 = 0),
Z
Z
1
1
ak =
sin[(k + 1)t] dt
sin[(k 1)t] dt
0
0




1 cos[(k + 1)t]
1 cos[(k 1)t]
=
+

k+1

k1
0
0


k+1 1]
1
1
2[(1)
1

=
.
= [(1)k+1 1]

k+1 k1
(k 2 1)
MA3PR

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

21010307

Therefore it follows that, for all odd values of k, ak = 0. As such we can now write the
function f (t) = | sin t|, for even n, as a Fourier trigonometric polynomial
n/2
2
4X
1
| sin t|
cos 2kt.

4k 2 1

(3.3.4)

k=1

The first few trigonometric polynomial approximations for f (x) = | sin t| are given below in
Figure 3. The code used to generate this plot is given in section (5.2) of this report.
Figure 3: A plot of the function f (t) = | sin t| and the approximating trigonometric polynomials p2 (t), p4 (t), p6 (t), p8 (t), p10 (t).
Original Function
p2 (t)

p4 (t)
p6 (t)
p8 (t)
p10 (t)

0.8

0.6

0.4

0.2

0
-

-/2

-/3

/3

/2

From this plot one can observe that as the degree of the approximation increases, the
polynomial converges to the original function. In other words we have,
max (t) = || sin t| pn (t)| 0,

as n .

(3.3.5)

This observation is confirmed further when analysing the computed maximum error between
the original function f (t) and each of the approximating polynomials in the plot above.
These values are given in Table 1.
Table 1: A table of the computed maximum absolute error values || sin(t)| pn (t)| in the
interval [, ] for each approximation.
Approximating Polynomial
p2 (t)
p4 (t)
p6 (t)
p8 (t)
p10 (t)

MA3PR

|| sin(t)| pn (t)|
0.21221
0.12732
0.09095
0.07074
0.05787

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

3.3.2

21010307

Approximation of f (t) = t2 using Fourier Trigonometric Polynomials

In this further example we now consider approximating the periodic function f (t) = t2 .
Note that f (t) is an even function again, as such bk = 0 and we can compute the other
coefficients as follows
1
a0 =

2
t dt =

Z
0

t2 dt =

2 2
,
3

and
Z
2 2
t cos kt dt
0

2  
2
2 2 2
2
=
2n
cos
kt
+
(k

2
)
sin
kt
0
k3 3

2
4(1)k
= 3 3 (2 3 k) cos k + (k 2 4 2 2 ) sin k =
.
k
k2

ak =

Hence we can approximate the function f (t) = t2 using the following Fourier trigonometric
polynomials,
n
2 X 4(1)k
2
t
+
cos kt.
(3.3.6)
3
k2
k=1

Figure 4: A plot of the function f (t) = t2 and the approximating trigonometric polynomials
p2 (t), p4 (t), p6 (t), p8 (t), p10 (t).
10

Original Function
p2 (t)

p4 (t)
p (t)
6

p (t)
8

p10 (t)

7
6
5
4
3
2
1
0

-/2

-/3

/3

/2

As with the previous example in section (3.3.1), we have that the maximum error between
the original function and the approximating polynomial converges to zero as the degree of
MA3PR

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

21010307

the polynomial increases, or


max (t) = |t2 pn (t)| 0,

as n .

Once again a table has been constructed to show the maximum absolute error values between
the original function and approximating polynomials of increasing degree.
Table 2: A table of the computed maximum absolute error values |t2 pn (t)| in the interval
[, ] for each interpolant.
Degree of Interpolant
p2 (t)
p4 (t)
p6 (t)
p8 (t)
p10 (t)

3.4

|t2 pn (t)|
1.57974
0.88529
0.61418
0.47005
0.38067

Discrete Least Squares Approximation

This section discusses a different method of best approximating a periodic function. Here
we look to compute the discrete least squares approximation of a function given the function
values at specific points. Suppose we have 2m data points in a given closed interval defined
by [(tj , yj )]2m1
j=0 (Burden and Faires (1993)). In what follows we consider the interval [, ]
however any closed interval can be established by using a simple linear transformation.
Given that we have 2m data points, we can define each data point as

tj = +

j
m


,

for each j = 0, 1, . . . , 2m 1.

(3.4.1)

The goal here is to minimise the error given by,


(Pn ) =

2m1
X

[yi Pn (ti )]2 ,

(3.4.2)

i=1

where Pn (t) is the approximating trigonometric polynomial. In other words we must find the
coefficients a0 , a1 , . . . , an , b1 , b2 , . . . , bn1 such that we minimise (see Chapter 8.5 of Burden
and Faires (1993)),
(Pn ) =

2m1
X
i=0

"

n1

k=0

k=1

X
a0 X
+
ak cos kti +
bk sin kti
yi
2

#)2
.

(3.4.3)



We can define the coefficients using the fact that we know that the set of functions 0 , 1 , . . . , 2n1
defined in (3.1.7) are orthogonal with respect to summation over equally spaced points in
[, ] (see Chapter 8.2 of Kress (1998)). As such, for each k 6= n,
2m1
X

k (ti )n (ti ) = 0,

(3.4.4)

i=0

MA3PR

10

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

21010307

and the constants in the summation that minimise (Pn ) are


ak =

2m1
1 X
yi cos kti ,
m

for each k = 0, 1, . . . , n,

(3.4.5)

for each k = 1, 2, . . . , n 1.

(3.4.6)

i=0

2m1
1 X
bk =
yi sin kti ,
m
i=0

The proof of the which is given in Chapter 8.5 of Burden and Faires (1993). In the following
section an example of using this technique is shown and the accuracy in approximation
is analysed to determine if this method provides any useful approximations to periodic
functions.
3.4.1

Approximation of f (t) = t2 + cos 2t using Discrete Least Squares Methods

Here we begin with computing the trigonometric polynomial of degree 2 for f (t) = t2 +
cos 2t where t [, ]. Let m = 3, then it follows that the approximating trigonometric
polynomial of degree 2 is given by
P2 (t) =

a0
+ a1 cos t + b1 sin t + a2 cos 2t,
2

where the coefficients are found by evaluating the sums defined in (3.4.5) and (3.4.6). In
this case we have,



 
 
 
1
2
2
a0 =
f () + f
+f
+ f (0) + f
+f
= 6.94528,
3
3
3
3
3





 
 
1
2
2
a1 =
f () cos() + f
cos
+f
cos
+ f (0) cos(0)
3
3
3
3
3
 
 
 
 
2
2
cos
+f
cos
= 4.38649,
+f
3
3
3
3







 
1
2
4
2
a2 =
f () cos(2) + f
cos
+f
cos
+ f (0) cos(0)
3
3
3
3
3







 
2
2
4
+f
cos
+f
cos
= 2.46217,
3
3
3
3





 
 
2
2
1
b1 =
f () sin() + f
sin
+f
sin
+ f (0) cos(0)
3
3
3
3
3





 
 
2
2
+f
sin
= 0.
sin
+f
3
3
3
3
Hence it follows that
P2 (t) = 3.47624 4.38649 cos t + 2.46217 cos 2t.
We can extend the method to use higher degree approximating polynomials, for example
the approximation polynomial of degree 3 is given by,
P3 (t) =
MA3PR

a0
+ a1 cos t + b1 sin t + a2 cos 2t + b2 sin 2t + a3 cos 3t.
2
11

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

21010307

Since we already know a0 , a1 , a2 and b1 for m = 3, we only need to calculate b2 and a3 to


find the polynomial of degree 3. It follows that, using the same method as above,
b2 = 0,
a3 = 1.09662.
Thus the discrete least squares trigonometric polynomial of degree 3 approximating f (t) =
t2 + cos 2t is given by
P3 (t) = 3.47624 4.38649 cos t + 2.46217 cos 2t 1.09662 cos 3t.

Figure 5: A plot of the function f (t) = t2 + cos 2t and the approximating discrete least
squares trigonometric polynomials p2 (t) and p3 (t).
12
Original Function
p2 (t)
p3 (t)

10

0
-4

-3

-2

-1


Table 3: A table of the computed maximum absolute error values | t2 + cos 2t pn (t)| in
the interval [, ] for approximating polynomials of degree 2 and 3.

Approximating Polynomial | t2 + cos 2t pn (t)|
p2 (t)
1.16327
p3 (t)
1.08721
In general the accuracy in approximating functions increases as n . It is also the
case that as you increase m, the accuracy increases even if you use the same degree of
approximating polynomial. This is simply due to the fact that you have more discrete
points at which to fit your approximation.
MA3PR

12

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

21010307

Conclusion

Many theories and methods were uncovered during the course of this research undertaken
into the field of Trigonometric Interpolation and Approximation Theory and this report
acts as a documentation of the key findings of said research. The idea of being able to
interpolate any given data set defined in a closed interval by a trigonometric polynomial
is invaluable, and its effectiveness in application is shown in section (2.1) and (2.2) of this
report. Both discrete and continuous cases are considered as an approximation of a given
periodic function.
It is the findings of this report that approximation of a periodic function using the Continuous Fourier Least-Squares technique shown in section (3.3) minimises the error between
the original function and the approximation. Since we proved in the examples (3.3.1) and
(3.3.2) that the maximum absolute error converges to zero as the degree of the approximating polynomial gets very large, it follows that we can use this technique for any periodic
function with extremely low error if approximating using a high degree trigonometric polynomial. Hence given any periodic function defined on a closed interval, we can apply this
theory to obtain an accurate approximation. In the discrete case, the error is shown to
slightly decrease coinciding with an increase in the degree of the approximating polynomial.
However this method is much more time consuming and in general the accuracy is lower
than that of the continuous case.
Overall the benefits of using trigonometric functions to interpolate and approximate functions are described and shown throughout this report, and hence this document acts as
reinforcement that trigonometric interpolation and best approximation still provide useful
results today. This field of Interpolation and Approximation Theory remains an active area
of research in Numerical Analysis and as such the methods described here are expected be
developed and improved over time.

MATLAB Source Code

This area of the report supplies the reader with the MATLAB source code used to generate
the various plots and figures given previously. All code in this section has been commented
for readability and the reader is encourage to use the code for themselves as examples to
show the key concepts discussed previously.

5.1
1
2
3
4

Source Code to Compute the Lagrange Interpolant

% L a g r a n g e I n t e r p : Given a f u n c t i o n , c a l c u l a t e t h e Lagrange
% interpolant .
%
% Author 21010307

5
6
7

c l o s e a l l % Close a l l f i g u r e s .
c l e a r a l l % C l e a r t h e command window .
MA3PR

13

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

8
9
10
11

12

13
14

21010307

n o p o i n t s = 3 ; % Number o f i n t e r p o l a t i o n p o i n t s .
a = p i ; % I n t e r v a l s t a r t p o i n t .
b = p i ; % I n t e r v a l end p o i n t .
x = l i n s p a c e ( a , b , n o p o i n t s ) ; % D e f i n e our i n t e r p o l a t i o n p o i n t s a s a
vector .
y = s i n ( x ) ; % Compute our f u n c t i o n v a l u e s a t each i n t e r p o l a t i o n
point .
x i = l i n s p a c e ( a , b ) ; % D e f i n e t h e whole i n t e r v a l .
f = s i n ( x i ) ; % Compute t h e f u n c t i o n o v e r t h e whole i n t e r v a l .

15
16
17
18
19
20
21
22

23
24
25
26

N = length (x) 1;
Ni = l e n g t h ( x i ) ;
L = o n e s ( Ni ,N+1) ;
f o r i = 1 : (N+1)
f o r j = 1 : (N+1)
i f ( i = j )
L ( : , i ) = L ( : , i ) . ( xi x ( j ) ) / ( x ( i )x ( j ) ) ; %
Compute t h e Lagrange i n t e r p o l a n t from
definition .
end
end
end
y i = yL ; % M u l t i p l y our Lagrange c o e f f i c i e n t s with t h e f u n c t i o n
values .

27
28
29
30
31

p l o t ( xi , f ) % P l o t t h e o r i g i n a l f u n c t i o n .
h o l d on
p l o t ( xi , yi , g , x , y , b ) % P l o t our i n t e r p o l a n t .
l e g e n d ( Function , I n t e r p o l a n t ) % Add a l e g e n d .

5.2
1

Source Code for Sections (3.3.1) and (3.3.2)

% ContLeastSq : Given a p e r i o d i c f u n c t i o n f ( t ) , compute t h e


continuous l e a s t
% s q u a r e s polynommial a p p r o x i m a t i o n .

3
4
5
6
7

c l o s e a l l % C l o s e a l l f i g u r e windows .
c l e a r a l l % C l e a r t h e command window .
syms t k n % D e f i n e our u n d e f i n e d v a r i a b l e s a s s y m b o l i c v a r i a b l e s .
a = @( f , t , k ) i n t ( f c o s ( k t ) / pi , t , pi , p i ) ; % From t h e d e f i n i t i o n o f
ak .
b = @( f , t , k ) i n t ( f s i n ( k t ) / pi , t , pi , p i ) ; % From t h e d e f i n i t i o n o f
bk .
f s = @( f , t , n ) a ( f , t , 0 ) /2 + . . .

MA3PR

14

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

21010307

symsum ( a ( f , t , k ) c o s ( k t ) + b ( f , t , k ) s i n ( k t ) , k , 1 , n ) ; % From
the d e f i n i t i o n of a Fourier t r i g o n o m e t r i c polynomial .

10

11
12

f = t 2 ; % The o r i g i n a l f u n c t i o n we wish t o i n t e r p o l a t e . This can


be changed t o any g i v e n f u n c t i o n .

13
14

15
16
17

18
19
20
21

22
23
24

25

e z p l o t ( f ,[ pi , p i ] ) % P l o t t h e o r i g i n a l f u n c t i o n on t h e g i v e n
interval .
h o l d on
f o r n=2:2:10
e z p l o t ( f s ( f , t , n ) ,[ pi , p i ] ) % P l o t t h e i n t e r p o l a n t s from d e g r e e 2
to degree 10.
h o l d on
end
hold o f f
l e g e n d ( O r i g i n a l Function , p { 2 } ( t ) , p { 4 } ( t ) , p { 6 } ( t ) , p
{8}( t ) , p {10}( t ) )
title ( ) ;
ax = gca ;
ax . XTick = [ p i 2 p i /3 p i /3 0 p i /3 2 p i /3 p i ] ; % Change t h e t i c k
values to increments of pi .
ax . XTickLabel = { \ p i , \ p i /2 , \ p i /3 , 0 , \ p i /3 , \ p i /2 , \ p i
} ; % Change t h e l a b e l s t o i n c r e m e n t s o f p i .

5.3
1

Source Code for Section (3.4.1)

% D i s c L e a s t S q : Given a p e r i o d i c f u n c t i o n f ( t ) , compute t h e
discrete least
% s q u a r e s polynommial a p p r o x i m a t i o n .

3
4
5
6

t = l i n s p a c e (pi , p i ) ;
y = t .2 + cos (2 t ) ; % Define the o r i g i n a l f u n c t i o n .
p l o t ( t , y ) % Plot the o r i g i n a l f u n c t i o n .

7
8
9

10

11

12

f = @( x ) x 2 + c o s ( 2 x ) ;
a0 = ( f ( p i ) + f (( 2 p i ) / 3 )+ f (( p i / 3 ) )+ f ( 0 ) + f ( ( p i / 3 ) ) + f ( ( 2
p i ) / 3 ) ) / 3 ; % From d e f i n i t i o n o f a0 .
a1 = ( f ( p i ) c o s ( p i ) + f (( 2 p i ) / 3 ) c o s (( 2 p i ) / 3 )+ f (( p i / 3 ) )
c o s (( p i / 3 ) ) + f ( 0 ) c o s ( 0 ) + f ( ( p i / 3 ) ) c o s ( ( p i / 3 ) ) + f ( ( 2 p i )
/ 3 ) c o s ( ( 2 p i ) / 3 ) ) / 3 ; % From d e f i n i t i o n o f a1 .
a2 = ( f ( p i ) c o s (2 p i ) + f (( 2 p i ) / 3 ) c o s (( 4 p i ) / 3 )+ f (( p i / 3 ) )
c o s (( 2 p i / 3 ) ) + f ( 0 ) c o s ( 0 ) + f ( ( p i / 3 ) ) c o s ( ( 2 p i / 3 ) ) + f ( ( 2
p i ) / 3 ) c o s ( ( 4 p i ) / 3 ) ) / 3 ; % From d e f i n i t i o n o f a2 .
a3 = ( f ( p i ) c o s (3 p i ) + f (( 2 p i ) / 3 ) c o s (( 6 p i ) / 3 )+ f (( p i / 3 ) )
c o s (( 3 p i / 3 ) ) + f ( 0 ) c o s ( 0 ) + f ( ( p i / 3 ) ) c o s ( ( 3 p i / 3 ) ) + f ( ( 2
MA3PR

15

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

13

14

21010307

p i ) / 3 ) c o s ( ( 6 p i ) / 3 ) ) / 3 ; % From d e f i n i t i o n o f a3 .
b1 = ( f ( p i ) s i n ( p i ) + f (( 2 p i ) / 3 ) s i n (( 2 p i ) / 3 )+ f (( p i / 3 ) )
s i n (( p i / 3 ) ) + f ( 0 ) s i n ( 0 ) + f ( ( p i / 3 ) ) s i n ( ( p i / 3 ) ) + f ( ( 2 p i )
/ 3 ) s i n ( ( 2 p i ) / 3 ) ) / 3 ; % From d e f i n i t i o n o f b1 .
b2 = ( f ( p i ) s i n (2 p i ) + f (( 2 p i ) / 3 ) s i n (( 4 p i ) / 3 )+ f (( p i / 3 ) )
s i n (( 2 p i / 3 ) ) + f ( 0 ) s i n ( 0 ) + f ( ( p i / 3 ) ) s i n ( ( 2 p i / 3 ) ) + f ( ( 2
p i ) / 3 ) s i n ( ( 4 p i ) / 3 ) ) / 3 ; % From d e f i n i t i o n o f b2 .

15
16
17

18
19
20

21
22
23

p2 = ( a0 / 2 ) + a1 c o s ( t ) + a2 c o s ( 2 t ) + b1 s i n ( t ) ; % From t h e
d e f i n i t i o n o f our 2nd d e g r e e a p p r o x i m a t i o n .
h o l d on
p l o t ( t , p2 ) % P l o t p2 .
p3 = ( a0 / 2 ) + a1 c o s ( t ) + a2 c o s ( 2 t ) + a3 c o s ( 3 t ) + b1 s i n ( t ) +
b2 s i n ( 2 t ) ; % From t h e d e f i n i t i o n o f our 3 rd d e g r e e
approximation .
h o l d on
p l o t ( t , p3 ) % P l o t p3 .
l e g e n d ( O r i g i n a l Function , p { 2 } ( t ) , p { 3 } ( t ) , p { 4 } ( t ) ) %
C r e a t e a l e g e n d f o r each p l o t .

MA3PR

16

Proposer - Dr Andrea Moiola

Part 3 Project (Project Report)

21010307

Bibliography

Burden, Richard L. and Douglas J. Faires (1993), Numerical Analysis, Boston: PWS-Kent
Publication Co.
Kress, Rainer (1998), Graduate Texts in Mathematics, Numerical Analysis, New York:
Springer.
Quarteroni, Alfio, Riccardo Sacco, and Fausto Saleri (2000), Numerical Mathematics, New
York: Springer.
Atkinson, K. and Han, W. (2005), Theoretical Numerical Analysis: A Functional Analysis
Framework, New York: Springer.

MA3PR

17

Proposer - Dr Andrea Moiola

You might also like