User:Yongtao-Li/HW2.9

=Problem 2.9: "Gauss-Legendre Quadrature and Runge's phenomenon"=

Given
Legendre polynomial

Find
A) Use (9.1) to generate $$ {P_5}(x) $$ and Matlab command "roots" to compute the roots of $$ {P_5}(x) $$ to check values in table on p7-5. Plot the roots on $$ [-1,+1] $$ using Matlab "plot" command.

B) Repeat the above for $$ {P_{10}}(x) $$ and observe the location of roots near end points -1 and +1.

Solution
A) Substitute n=5 in (9.1) and then can get $$ {P_5}(x) $$:

Use the following codes in Matlab :

p=[63 0 -70 0 15 0]/8 roots(p)

we can get the roots for $$ {P_5}(x) $$: ans = 0  -0.9062   -0.5385    0.9062    0.5385

The above answers are exactly the same as the data in table on p7-5.

Use the "plot" command we can get the distribution of roots on $$ [-1,+1] $$ as following:



B) Substitute n=10 in (9.1) and then can get $$ {P_{10}}(x) $$:

Use the following codes in Matlab :

p=[46189 0 -109395 0 90090 0 -30030 0 3465 0 -63]/256 roots(p)

we can get the roots for $$ {P_{10}}(x) $$: ans = -0.9739  -0.8651   -0.6794    0.9739    0.8651    0.6794   -0.4334    0.4334   -0.1489    0.1489

The above answers are exactly the same as the data in table on p7-5.

Use the "plot" command we can get the distribution of roots on $$ [-1,+1] $$ as following:



From the above image, we can observe that quadrature nodes become more dense near the end points. That means the interpolation with high order polynomial may has more oscillation near the edge of interval region because the interpolation only exactly accurate at the quadrature nodes and this phenomenon is so called Runge's phenomenon.