 # Mathematics1 Mathematics 1 Applied Informatics Štefan BEREŽNÝ.

## Presentation on theme: "Mathematics1 Mathematics 1 Applied Informatics Štefan BEREŽNÝ."— Presentation transcript:

Mathematics1 Mathematics 1 Applied Informatics Štefan BEREŽNÝ

5 th lecture

MATHEMATICS 1 Applied Informatics 3 Štefan BEREŽNÝ Contents Numerical integration Rectangular Rule Trapezoidal Rule Simpson’s Rule:

MATHEMATICS 1 Applied Informatics 4 Štefan BEREŽNÝ Numerical integration Definition: The partition D =  x 0, x 1, …, x n  of interval  a, b  is given by a = x 0  x 1  …  x n-1  x n = b. We will get n sub-intervals  x 0, x 1 ,  x 1, x 2 ,  x 2, x 3 , …,  x n-2, x n-1 ,  x n-1, x n  of the same length h, where x k = a + k  h for k = 1, 2, 3, …, n and

MATHEMATICS 1 Applied Informatics 5 Štefan BEREŽNÝ Numerical integration Notation: We shall denote y k = for k = 1, 2, 3, …, n.

MATHEMATICS 1 Applied Informatics 6 Štefan BEREŽNÝ Rectangular Rule We approximate function f by a constant function on each sub-interval  x k-1, x k . The constant function is uniquely determined by the one point. Then the considered constant function is: y = y k on interval  x k  1, x k . Its integral I k in the interval  x k  1, x k  represents the area of the rectangle and so I k = h  y k.

MATHEMATICS 1 Applied Informatics 7 Štefan BEREŽNÝ Rectangular Rule If we add all the numbers I 1, I 2, …., I n, we obtain:

MATHEMATICS 1 Applied Informatics 8 Štefan BEREŽNÝ Rectangular Rule S n is the approximate value of the Riemann integral of function f on the interval  a, b . It is the sum of the areas of n rectangles constructed on the intervals  x 0, x 1 ,  x 1, x 2 ,  x 2, x 3 , …,  x n-2, x n-1 ,  x n-1, x n . The accuracy of the approximation should increase with increasing n.

MATHEMATICS 1 Applied Informatics 9 Štefan BEREŽNÝ Trapezoidal Rule We shall denote y k = f ( x k ). We approximate function f by a linear function on each sub-interval  x k-1, x k . The linear function is uniquely determined by the requirement that its graph (a straight line) passes through two chosen points. Let us choose the points  x k  1, y k  1  and  x k, y k . Then the considered linear function is: y = y k  1 + (( y k  y k  1 )  ( x  x k  1 ))/ h. Its integral I k in the interval  x k  1, x k  represents the area of the trapezoid and so I k = ( h  ( y k  1, y k ))/2.

MATHEMATICS 1 Applied Informatics 10 Štefan BEREŽNÝ Trapezoidal Rule If we add all the numbers I 1, I 2, …., I n, we obtain:

MATHEMATICS 1 Applied Informatics 11 Štefan BEREŽNÝ Trapezoidal Rule S n is the approximate value of the Riemann integral of function f on the interval  a, b . It is the sum of the areas of n trapezoids constructed on the intervals  x 0, x 1 ,  x 1, x 2 ,  x 2, x 3 , …,  x n-2, x n-1 ,  x n-1, x n . It can naturally be expected that the finer the partition of the interval  a, b , the better is the approximation of the Riemann integral.

MATHEMATICS 1 Applied Informatics 12 Štefan BEREŽNÝ Trapezoidal Rule In other words, the accuracy of the approximation should increase with increasing n and with decreasing h. This expectation is correct. It can be proved that if function f has a continuous second derivative f  in interval  a, b  and M 2 is the maximum of  f  in  a, b  then the following error estimate holds:

MATHEMATICS 1 Applied Informatics 13 Štefan BEREŽNÝ Simpson’s Rule Let us now choose an integer n that it is even and let us approximate function f by a quadratic polynomial on each of the sub-intervals  x 0, x 2 ,  x 2, x 4 ,  x 4, x 6 , …,  x n-4, x n-2 ,  x n-2, x n . The quadratic polynomial on the sub-interval  x k  2, x k  for k = 2, 4, 6, …, n is uniquely determined if we require that its graph (a parabola) passes trough three chosen points. Let the three chosen points be  x k  2, y k  2 ,  x k  1, y k  1  and  x k, y k .

MATHEMATICS 1 Applied Informatics 14 Štefan BEREŽNÝ Simpson’s Rule The coefficients and the integral of such a quadratic polynomial in the interval  x k  2, x k  can be relatively easily evaluated - you can verify for yourself that the integral I k = h  ( y k  2 + 4  y k  1 + y k )/3. Summing all the numbers I 2, I 4, …., I n, we obtain:

MATHEMATICS 1 Applied Informatics 15 Štefan BEREŽNÝ Simpson’s Rule S n is the approximate value of the Riemann integral of function f on the interval  a, b . It can be proved that if the fourth derivative f (4) of function f is continuous in  a, b  and M 4 is the maximum of  f (4)  in  a, b  then the following error estimate holds:

MATHEMATICS 1 Applied Informatics 16 Štefan BEREŽNÝ Thank you for your attention.