Worksheet 3
Worksheet 3
−π π x x
0 2π −π 0 π 2π
−1
x
−π 0 π 2π
c) Repeating ramp.
1
Exercise 2: DFT and Least Square Approximation
For a given N ∈ N and A ∈ R, let ∆x = A/N .
∀n, 0 ≤ n < N , xn = n∆x and fn ∈ C form the data pair (xn , fn ). Note that the xn are the equally
spaced point of the interval [0, A − ∆x].
We want to find an approximation to the data using the N -trigonometric polynomial φN , given by
N−1
φN (x) = ∑ αk ei2πkx/A , (1)
k=0
the function φN is called a trigonometric polynomial because it is a polynomial in the quantity ei2πx/A .
The approximation should fit the least square criterion, where we minimize the discrete least squa-
res error E defined as
N−1
E= ∑ | fn − φN (xn )|2 (2)
n=0
Find the N coefficients α0 , . . . , αN−1 . Do you know an algorithm to compute them efficiently ?
Hint: use the expression for the partial derivative of the error E :
" !#
N−1 N−1
∂E
= ∑ e−i2πnk/N fn − ∑ α p ei2πnp/N , (3)
∂ αk n=0 p=0
!
N−1
1 1 πnk 1
Fk = f0 + ∑ fn cos + fN cos(πk) . (5)
N 2 n=1 N 2
c) Let FFT(f,N) be a procedure that computes the coefficients Fk efficiently (according to equa-
tion (4)) from a field f which consists of 2N values fn . (The result is written back to field f)
Write a short procedure DCT(g,N) which uses procedure FFT to compute the coefficients
Fk for k = 0, . . . , N from equation (5) for the (non-symmetrical) data f0 , . . . , fN , stored in the
parameter field g.