

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
Solutions to problem 3 of the amsc/cmsc 460 homework, which involves using the method of undetermined coefficients to derive the 'half simp' formula and approximating integrals using gauss-leguerre quadrature. Matlab scripts to solve the linear systems and find the abscissas and weights for the quadrature formula.
Typology: Assignments
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Show work for all three problems. If you used Matlab, hand in scripts showing what you did. The following are useful fodder for the Matlab’s help command: horzcat, vertcat, mldivide, roots.
1 / 2
f (x) dx ∼= A 0 f (0) + A 1 f (1/2) + A 2 f (1);
[Hint: Use Matlab to solve the linear system.]
Answer: We have the three equations
∫ (^1) 1 / 2 1 dx^ =^
1 ∫ 2 =^ A^0 +^ A^1 +^ A^2 1 1 / 2 x dx^ =^
3 8 =^
1 ∫ 2 A^1 +^ A^2 1 1 / 2 x
(^2) dx = 7 24 =^
1 4 A^1 +^ A^2
the solution is
format long C = [1 1 1; 0, 1/2, 1; 0, 1/4, 1]; b = [1/2; 3/8; 7/24]; A = C\b; A = -0.
We wish to approximate ∫ (^) ∞
0
f (x)e−x^ dx = A 0 f (0) + A 1 f (3) + A 2 f (5).
Use the method of undetermined coefficients to determine the weights Ai. Apply your quadrature rule to approximate
∫ (^) ∞
0
sechx dx =
π 2
[Hints: First find a formula for
0 x
ne−x (^) dx. It will then be easy to set up a 3×3 for
the Ai.]
Answer: The system is determined as in the first problem. Using the fact that
∫ (^) ∞ 0 x
n (^) = n!, we get
the following Matlab script.
C = [1, 1, 1; 0, 3, 5; 0, 9, 25]; b = [1, 1, 2]’; A = C\b;
A =
-0.
The evaluation of the integral (∗) goes as follows.
absc = [0, 3, 5]; f = sech(absc).exp(absc); apprx = fA
apprx =
Compute the abscissas and weights for the Gauss–Leguerre quadrature formula ∫ (^) ∞
0
f (x)e−x^ dx = A 0 f (x 0 ) + A 1 f (x 1 ) + A 2 f (x 2 );
Use it to approximate the integral (∗). Compare your results with those of Problem 2. [Hints: This involves three steps. First, you must find the coefficients of the cubic Laguerre polynomial p(x) = x^3 − ax^2 − bx − c satisfying
0 x
ip(x)e−x (^) = 0 (i = 0, 1 , 2).
Then you must find the roots of this polynomial. Finally, you must determine the weights as usual. A three line Matlab script will do all of this.]
Answer: Here is the matlab script that evaluates the abscissas and weights.
coef = [1;-([2,1,1;6,2,1;24,6,2][6;24;120])] absc = sort(roots(coef)) wgt = [1 1 1;... absc(1), absc(2), absc(3);... absc(1)^2, absc(2)^2, absc(3)^2][1;1;2]
coef =
-9.
-6. absc =