0% found this document useful (0 votes)
12 views2 pages

Tutorial 11

The document outlines tutorial problems related to numerical analysis, focusing on quadrature formulas and Simpson's rule derivation. It includes tasks for programming Gauss-Legendre quadrature, detailing how to implement the method and compute integrals. Additionally, it emphasizes the importance of precision and error analysis in numerical integration techniques.

Uploaded by

kynapadhai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Tutorial 11

The document outlines tutorial problems related to numerical analysis, focusing on quadrature formulas and Simpson's rule derivation. It includes tasks for programming Gauss-Legendre quadrature, detailing how to implement the method and compute integrals. Additionally, it emphasizes the importance of precision and error analysis in numerical integration techniques.

Uploaded by

kynapadhai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Numerical Analysis I.

Tutorial and laboratory 11

1. TUTORIAL PROBLEMS

1. Find a, b, c and d so that the quadrature formula


Z 1
f (x)dx ≈ af (−1) + bf (1) + cf 0 (−1) + df 0 (1)
−1

has degree of precision 3.

2. (i) Derive the Simpson’s rule with error by using


Z 2
f (x)dx = a0 f (0) + a1 f (1) + a2 f (2) + kf (4) (ξ)
0

for all functions f (x) which are four time differentiable (ξ depends on f ). Let
f (x) = 1, x, x2 to find the coefficients a0 , a1 and a2 . Verify that the formula
holds for f (x) = x3 . Then find k by using f (x) = x4 .
(ii) From part (i), by using a change of variables, deduce the Simpson’s
rule with error on an interval [a, b].

3. (i) Given that the quadrature rule


Z b
b + 2a 2b + a
f (x)dx ≈ αf ( ) + βf ( ),
a 3 3

is exact for f (x) = 1 and f (x) = x. Find α and β.


(ii) Given further that there is a constant k so that for all twice differen-
tiable functions f (x), the error of the rule is of the form

k(b − a)3 f 00 (ξ),

where ξ ∈ [a, b]. Find k.

1
2. PROGRAMMING

Task 1. Download the file gauleg.py. The file contains the function
gauleg(n) which returns the n nodes t0 , t1 , . . . , tn−1 and the weights c0 , c1 , . . . , cn−1
for the Gauss-Legendre rule on [−1, 1], i.e.
Z 1 n−1
X
f (t)dt ≈ ci f (ti ).
−1 i=0

Task 2. The function GL reads two end points a and b and the number
of nodes n for the Gauss-Legendre quadrature rule. It returns the approx-
imating integral of a function f (x) over the interval [a,b] by applying the
Gauss-Legendre rule for n points.

def GL(a,b,n):
t,c=gauleg(n)
I=0
.....
return I
The aim is to compute the Gauss-Legendre approximating integral
n−1
b−aX (b − a)ti + (a + b)
I= ci f ( ).
2 i=0 2

Fill in the gap to:

1. For each index i, transform the node ti to

(b − a)ti + (a + b)
x= ,
2
and add ci f (x) to I.

2. Then multiply I by (b-a)/2.

Task 3 Define the function f (x) as ex . Let a = 0 and b = 5. Start


with n = 2 and then increase n to see that the result converges to the exact
integral.

You might also like