Reference no: EM132210171
In this assignment, we develop a quadrature method for computing -1∫1 g(x) √(1 - x2)dx for a given g : [-1, 1] → R. You can use the built-in routines to compare your results and compute errors for use in §B.
A1. Show that p0(x) = 1 and p1(x) = 2x . By using a trigonometric identity, show that
pn(x) = 2xpn-1(x) - pn-2(x), n = 2, 3, .....
Hence, show that pn(x) is a polynomial of degree n and that p0,......, pn form a basis for pn.
A2. Let x1, ......., xn denote the roots of pn(x) . Show that the matrix
![1810_Matrix.jpg](https://secure.expertsmind.com/CMSImages/1810_Matrix.jpg)
is non-singular. Hence, show that there exist w1, ..... wn, such that
![147_figure.jpg](https://secure.expertsmind.com/CMSImages/147_figure.jpg)
HINT: Suppose that there exists a c 2 Rn such that c TJn = 0 .
A3. By making a substitution, show that
-1∫1 pn(x)pm(x)√(1 - x2)dx = 0, n ≠ m
A4. By using the basis {p0, .....}, for pn for pn and A3, prove that
-1∫1 p(x)√(1 - x2)dx = Σi=1n p(xi)wi, ∀p∈pn,
for the xi and wi defined above.
Now show that the relationship also holds for p∈p2n-1 to show the quadrature rule has degree of precision at least 2n - 1 and hence is a Gaussian quadrature rule.
A5. Let q0(x) := 1 and qn(x) := 2ndet(xl - An) for n = 1, 2, : : : , where An is the n × n matrix
![237_Matrix.jpg](https://secure.expertsmind.com/CMSImages/237_Matrix.jpg)
Show that qn = pn for n = 1, 2, : : : .
Hence, show that eigenvalues of An equal the quadrature nodes xi.
A6. Denote the ith column of Jn (from A2) by
vi = [p0(xi), p1(xi),........pn-1(xi)]T , i = 1.....n
Show that vi is an eigenvector of An corresponding to the eigenvalue xi. Hence, show that the quadrature weight
wi = A.(1/||vi||2) (vi1)2 , A := -1∫1√(1 - x2)dx = 1/2Π
where v1i is the first component of the ith eigenvector vi.
B Computing
B1. Write a MATLAB code to compute the quadrature nodes x1, ....... , xn and weights w1, ....., wn for the quadrature rule developed in §A.
Fill in
function [x,w]=getquad(n)%
% Return a vector of quadrature nodes x and weights w,
% of dimension n.
% ....
B2. Write a routine to evaluate the quadrature for a given function g . Fill in function out=myquad(g,x,w)%
% Evaluate sum_{i=1,...,n} w_i g(x_i)
assert (length(x)==length(w)) % error checking
%...
%...
out= % give return value
It should run with the call
myquad(@(x) x,x,w)
to evaluate -1∫1x√(1 - x2)dx. Verify the degree of precision is 2n - 1 for n = 10 (using MATLAB).
B3. Use the built-in MATLAB routines to find reference values for
-1∫1g(x)√(1 - x2)dx
in the case g1(x) = exp(x) and g2(x) = x sin(x) . We use these values in the next question to evaluate error. Note down the number of function evaluations, when using quad.
B4. Using the quadrature method developed in B2., evaluate
-1∫1gi(x)√(1 - x2)dx, for i = 1,2
Give a plot of the error against n , taking care to use an appropriate range of n and plot (e.g., loglog vs plot vs semilogx etc).
Compare the number of function evaluations used by the MATLAB routine quad and the method of B2.