Professional Documents
Culture Documents
Contents of lecture
Recall the discrete Poisson problem Recall methods used so far Exact solution by diagonalization Exact solution by Fast Sine Transform The sine transform The Fourier transform The Fast Fourier Transform The Fast Sine Transform Algorithm
u=0
(u +u ) =f xx yy
u=0
u=0
h = 1/(m + 1) gives n := m2 interior grid points Discrete approximation V = [vj,k ] Rm,m with vj,k u(jh, kh).
n.
Eigenpairs of T = diag(1, 2, 1) R
Let h = 1/(m + 1). We know that
T sj = j sj for j = 1, . . . , m, where
m,m
T SXS + SXST = h2 F
ST SXS 2 + S 2 XST S = h2 SF S
S 2 =I/(2h)
T S=SD
S 2 DXS 2 + S 2 XS 2 D = h2 SF S DX + XD = 4h4 SF S.
X is easy to nd
An equation of the form DX + XD = B for some B is easy to solve. Since D = diag(j ) we obtain for each entry
j xjk + xjk k = bjk
Algorithm
Algorithm 1 (A Simple Fast Poisson Solver).
m ; j,k=1 m j=1
= sin2 ((jh)/2)
(1)
Output is the exact solution of the discrete Poisson equation on a square computed in O(n3/2 ) operations. Only a couple of m m matrices are required for storage. Next: Use FFT to reduce the complexity to O(n log2 n)
wj =
k=1
sin
jk m+1
vk ,
j = 1, . . . , m
is the Discrete Sine Transform (DST) of v. In matrix form we can write the DST as the matrix times vector w = Sv, where S is the sine matrix. We can identify the matrix B = SA as the DST of A Rm,n , i.e. as the DST of the columns of A.
The product B = AS
The product B = AS can also be interpreted as a DST. Indeed, since S is symmetric we have B = (SAT )T which means that B is the transpose of the DST of the rows of A. It follows that we can compute the unknowns V in Algorithm 1 by carrying out Discrete Sine Transforms on 4 m-by-m matrices in addition to the computation of X .
= cos + i sin ,
R, i = 1 ei ei sin = 2i
Consider
N := e
2i/N
2 2 = cos i sin , N N
N N = 1
Note that
jk 2m+2 = e2jki/(2m+2) = ejkhi = cos(jkh) i sin(jkh).
zj =
k=1
(j1)(k1) N yk ,
j = 1, . . . , N
RN,N
Example
4 = exp2i/4 = cos( ) i sin( ) = i 2 2 F4 = 1 1 1 1 1 1 1 1 2 3 1 4 4 4 1 i 1 i = 2 4 6 1 1 1 1 1 4 4 4 3 6 9 1 4 4 4 1 i 1 i
k = 1, . . . , m.
1 F4 = 1 1 F2 = 1 1
1 1 i i i 1 i . F 4P 4 = 1 1 1 1 1 1 1 i 1 i i i 1 1 = 1 1 , D 2 = diag(1, 4 ) = F2 F2 D2 F 2 D 2 F 2 1 0 .
1 2
1 1
0 i
F 4P 4 =
F 2m P 2m =
where
Fm DmF m F m D m F m
(2)
2 m1 Dm = diag(1, N , N , . . . , N ).
(3)
Proof
Fix integers j, k with 0 j, k m 1 and set p = j + 1 and q = k + 1. m 2 m Since m = 1, N = m , and N = 1 we nd by considering elements in the four sub-blocks in turn (F 2m P 2m )p,q (F 2m P 2m )p+m,q (F 2m P 2m )p,q+m (F 2m P 2m )p+m,q+m = N = N = N = N
j(2k)
= = = =
jk m
(j+m)(2k)
(j+m)k
j(2k+1)
j jk N m
(j+m)(2k+1)
j(2k+1)
It follows that the four m-by-m blocks of F 2m P 2m have the required structure.
q 1 = F m w1 and q 2 = D m (F m w2 ).
Recursive FFT
Recursive Matlab function when N = 2k
(Recursive FFT ) function z=fftrec(y) n=length(y); if n==1 z=y; else q1=fftrec(y(1:2:n-1)); q2=exp(-2*pi*i/n). (0:n/2-1).*fftrec(y(2:2:n)); z=[q1+q2 q1-q2]; end
Algorithm 3.
Such a recursive version of FFT is useful for testing purposes, but is much too slow for large problems. A challenge for FFT code writers is to develop nonrecursive versions and also to handle efciently the case where N is not a power of two.
FFT Complexity
Let xk be the complexity (the number of ops) when N = 2k . Since we need two FFTs of order N/2 = 2k1 and a multiplication with the diagonal matrix D N/2 it is reasonable to assume that xk = 2xk1 + 2k for some constant independent of k. Since x0 = 0 we obtain by induction on k that xk = k2k = N log2 N . This also holds when N is not a power of 2. Reasonable implementations of FFT typically have 5
What is faster will depend on the programming of the FFT and the size of the problem.
T = 109 ops 10 years 1/2 hour 1/2 hour 8 sec 1/2 sec
= 1 1018 3