Mathematics 1 Applied Informatics tefan BEREN MATHEMATICS 1
Mathematics 1 Applied Informatics Štefan BEREŽNÝ MATHEMATICS 1 Applied Informatics
5 th lecture Štefan BEREŽNÝ MATHEMATICS 1 Applied Informatics
Contents • • Numerical integration Rectangular Rule Trapezoidal Rule Simpson’s Rule: Štefan BEREŽNÝ MATHEMATICS 1 Applied Informatics 3
Numerical integration Definition: The partition D = x 0, x 1, … , xn of interval a, b is given by a = x 0 x 1 … xn-1 xn = b. We will get n sub-intervals x 0, x 1, x 2, x 3 , … , xn-2, xn-1, xn of the same length h, where xk = a + k h for k = 1, 2, 3, …, n and Štefan BEREŽNÝ MATHEMATICS 1 Applied Informatics 4
Numerical integration Notation: We shall denote yk = for k = 1, 2, 3, … , n. Štefan BEREŽNÝ MATHEMATICS 1 Applied Informatics 5
Rectangular Rule We approximate function f by a constant function on each sub-interval xk-1, xk. The constant function is uniquely determined by the one point. Then the considered constant function is: y = yk on interval xk 1, xk. Its integral Ik in the interval xk 1, xk represents the area of the rectangle and so Ik = h yk. Štefan BEREŽNÝ MATHEMATICS 1 Applied Informatics 6
Rectangular Rule If we add all the numbers I 1, I 2, …. , In, we obtain: Štefan BEREŽNÝ MATHEMATICS 1 Applied Informatics 7
Rectangular Rule Sn 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 , … , xn-2, xn-1, xn. The accuracy of the approximation should increase with increasing n. Štefan BEREŽNÝ MATHEMATICS 1 Applied Informatics 8
Trapezoidal Rule We shall denote yk = f (xk). We approximate function f by a linear function on each sub-interval xk-1, xk. 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 xk 1, yk 1 and xk, yk. Then the considered linear function is: y = yk 1 + ((yk yk 1) (x xk 1))/h. Its integral Ik in the interval xk 1, xk represents the area of the trapezoid and so Ik = (h (yk 1, yk))/2. Štefan BEREŽNÝ MATHEMATICS 1 Applied Informatics 9
Trapezoidal Rule If we add all the numbers I 1, I 2, …. , In, we obtain: Štefan BEREŽNÝ MATHEMATICS 1 Applied Informatics 10
Trapezoidal Rule Sn 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 , … , xn-2, xn-1 , xn-1, xn. It can naturally be expected that the finer the partition of the interval a, b , the better is the approximation of the Riemann integral Štefan BEREŽNÝ MATHEMATICS 1 Applied Informatics . 11
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: Štefan BEREŽNÝ MATHEMATICS 1 Applied Informatics 12
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 , … , xn-4, xn-2 , xn -2, xn. The quadratic polynomial on the sub-interval xk 2, xk 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 xk 2, yk 2 , xk 1, yk 1 and xk, yk. Štefan BEREŽNÝ MATHEMATICS 1 Applied Informatics 13
Simpson’s Rule The coefficients and the integral of such a quadratic polynomial in the interval xk 2, xk can be relatively easily evaluated - you can verify for yourself that the integral Ik = h (yk 2 + 4 yk 1 + yk)/3. Summing all the numbers I 2, I 4, …. , In, we obtain: Štefan BEREŽNÝ MATHEMATICS 1 Applied Informatics 14
Simpson’s Rule Sn 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: Štefan BEREŽNÝ MATHEMATICS 1 Applied Informatics 15
Thank you for your attention. Štefan BEREŽNÝ MATHEMATICS 1 Applied Informatics 16
- Slides: 16