



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Spectral Method, Discussion, Matlab Code, Results
Typology: Study notes
1 / 5
This page cannot be seen from the preview
Don't miss anything!




0 0.5 1 1.5 2 2.5 3
0
1
Solution to d^2 y − (cos x)y = −1, n = 127
Part 2
This problem was examined in problem set 7, problem 4, part b. There, I
assumed a solution as a sum of sin junctions,
N ∑
k=
uk sin kx
I found that the equations for the coefficients in the optimal expansion could
be written as a tri-diagonal matrix. The elements of the matrix on the right
are,
π
k
δk odd =
8 π
1 k
k odd
0 k even
Assuming for the sake of representation that N is even,
− 2 · 1
2
2 1
2 1
2
u 1
u 2
. . .
. . .
uN − 1
uN
8 π 0 8 π
1 3 . . . 8 π
1 N − 1
0
The resulting spectral approximations for several values of N are shown in
figure 1.
Part 3
I find that the spectral solution is much more accurate than the numerical
approximation taking N = 8 terms in the spectral summation compared to
n = 8 interior mesh points. Because both methods rely on solving a tri-
diagonal system, the spectral method provides much greater accuracy with
similar computation time for small values of N.
0 0.5 1 1.5 2 2.5 3
0
1
Comparison of numerical approximation and spectral methods for solving d
2 y − y*cos(x)=−
Node approx. n= Node approx. n= N = 1 N = 2 N = 4 N = 8
Figure 2:
0 0.5 1 1.5 2 2.5 3
0
1
Comparison of n=8 node approximation with n=8 spectral approximation
Node Spectral
Figure 3: