matlab code
MATH466/46
2
Project 4. Due in class on Wed, Mar
1
8, 2020
Instruction: your project report should include necessary mathematical
justification, description, and details of your algorithms/conclusions
.
Your MATLAB codes and generated outputs may be attached in the end of the
report. Make sure you addressed all the questions in each problem. Both
the report and codes will be graded. Please submit a printed hard-copy.
Problem A (20 pts): Circulant Preconditioners for Toeplitz Systems
Toeplitz matrix arises in many different applications. Its matrix-vector product can be computed efficiently via fast
Fourier transform (FFT). Many circulant preconditioners have been proposed for solving Toeplitz systems. In this
project, we will compare several circulant preconditioners for solving various Toeplitz systems.
Task 1: Study Toeplitz matrix, Circulant matrix, and the use of FFT (read our Textbook Chap 10.1).
Read Chapters 1 and 3: https://ee.stanford.edu/~gray/toeplitz
Understand more on FFT: https://arxiv.org/pdf/1805.05533v2
Task 2: play and understand the following codes:
For any Circulant matrix πΆ, the matrix-vector products π₯ = πΆβ1π can also be computed via FFT:
1 n=10; C=gallerygallerygallery(‘circul’,(1:n));%Construct a Circulant matrix using (1:n) as 1st row
2 b=ones(n,1); x2=C\b; %Direct solve: O(n^3) operations
3 ev=fftfftfft(C(:,1));%the eigenvalues of C by FFT of its first column
4 x1= ifftifftifft(fftfftfft(b)./ev); %Solve C\b using FFT: O(n log n) operations
5 normnormnorm(x1-x2,inf) %should be zero
By embedding a Toeplitz matrix π into a Circulant matrix, the product ππ£ can also be computed via FFT:
1 n=10;t=(n:-1:1); T=toeplitztoeplitztoeplitz(t,t’); %construct a full symmetric Toeplitz matrix: T’=T
2 v=randrandrand(n,1);y2=T*v;%compute y2=T*v using direct multiplication: O(n^2) operations
3 gev = fftfftfft([t 0 t(n:-1:2)].’);%the eigenvalues of the embeding larger Circulant matrix
4 y = ifftifftifft(fftfftfft([v;zeroszeroszeros(n,1)]).*gev);%compute y1=T*v using FFT: only O(n log n) operations
5 y1 = y(1:n); %take the first half of the long vector
6 normnormnorm(y1-y2,inf) %should be close to zero
Task 3: understand the construction of 3 circulant preconditioners.
Let ππ be an π-by-π Toeplitz matrix with ππ(π, π) = π‘πβπ , where {π‘π }πβ1π=1βπ are given diagonals. We can define at least
3 different circulant preconditioners as follows:
1. Strangβs Preconditioner: Strangβs preconditioner ππ with ππ(π, π) = π πβπ is defined to be the circulant ma-
trix obtained by copying the central diagonals of ππ and bringing them around to complete the circulant
requirement. Assume π = 2π is even, the diagonals π π of ππ are given by
π π =

π‘π if 0 β€ π β€ π β 1
0 if π = π
π‘πβπ if π < π β€ π β 1
π βπ if (1 β π) β€ π < 0
.
2. T. Chanβs Preconditioner: T. Chanβs preconditioner πΆπ with πΆπ(π, π) = ππβπ is defined through minimizing
the difference betweenππ andπΆπ over all circulat matrices. The diagonals ππ ofπΆπ are given by (taking π‘βπ = 0)
ππ =
{
(πβπ)π‘π+ππ‘πβπ
π
if 0 β€ π β€ π β 1
ππ+π if (1 β π) β€ π < 0 .
3. R. Chanβs Preconditioner: R. Chanβs preconditioner π
π with π
π(π, π) = ππβπ is defined to make uses of all
the entries of ππ. The diagonals ππ of π
π are given by (taking π‘βπ = 0)
ππ =
{
π‘π + π‘πβπ if 0 β€ π β€ π β 1
πβπ if (1 β π) β€ π < 0
.
1
https://ee.stanford.edu/~gray/toeplitz
https://arxiv.org/pdf/1805.05533v2
(1) Use our PCG (mypcgfun.m) to solve the SPD Toeplitz systems πππ₯ = π with π = ππππ (π, 1) and
ππ(π, π) =
{
π2/3 if π == π
2(β1) πβπ
(πβπ)2 if π β π
.
Test with no preconditioner and the above circulant preconditioners, and compare their iteration numbers
and CPU times for different dimensions n=1e3*(1:5) (set max 10000 iterations and tolerance 10β7).
You can start with construction of all related full matrices for smaller π, but eventually all matrix-vector
products should be replaced by only FFT based codes for better efficiency and lower memory costs.
(2) Circulant preconditioners are attrative since they can be solved efficiently (π(π lnπ) operations) via FFT. As we
aready know, a tridiagonal matrix can also be solved very efficiently (π(π) operations) via Thomas algorithm.
Run your codes again with the following tridiagonal preconditioner, which works well for the given ππ:
1 Pn=gallerygallerygallery(‘tridiag’,n,-1,2,-1);
For benchmarking your own codes, below are the iteration numbers based on my implementation:
1 n None Strang T. Chan R. Chan Tridiag
2 1000 746 8 28 7 14
3 2000 1522 8 35 7 14
4 3000 2301 8 41 7 14
5 4000 3081 8 47 7 14
6 5000 3862 8 50 7 14
(3) Solve the same system using the Gaussian elimination method (GEsolver.m), what you observe in terms
of CPU times growth, in comparison with the above PCG solvers?
2