Całkowanie numeryczne

Katedra Technologii Maszyn i Automatyzacji Produkcji

Komputerowe Wspomaganie Procesów Technologii bezwiórowych

Całkowanie numeryczne metodą prostokątów, trapezów i Simpsona

Dawid Kulczykowski

III MiBM, LP2

1. Całkowanie numeryczne

Znaleźć całkę z funkcji $f\left( x \right) = \frac{1}{x}$ w przedziale $\left\lbrack \frac{1}{2},\frac{5}{2} \right\rbrack$

Dokładna równanie :


$$\int_{a}^{b}{f\left( x \right)dx = \int_{1/2}^{5/2}{\left( \frac{1}{x} \right)dx = |lnx|\left| \frac{\ ^{5/2}}{\ _{1/2}} \right.\ }} = \left( \ln\frac{5}{2} \right) - \left( \ln\frac{1}{2} \right) = 0,915180 - \left( - 0,693147 \right) = 1,609438$$

Tabela wyników :

n Całk.dokł Metoda Prostokątów Metoda trapezów Metoda Simsona
I I R In
0 1,609438
1 4,0/0,8 2
2 1,866666
3 1,735066
4 1,683560
5 1,65790
6 1,64359
7 1,63477
8 1,62888
9 1,62491
10 1,62216

Metoda prostokątów


I = ∫abf(x)dx = h * yi


$$h = \frac{b - a}{n}\ ,\ \ gdzie\ \ n = 1\ (ilosc\ przedzialow)$$


$$Blad\ metody\ R = \frac{{(b - a)}^{2}}{\text{Zn}}*\left\lbrack f^{'}(\xi) \right\rbrack,\ gdzie\ \ \xi = \left\lbrack a,b \right\rbrack,\ \xi = 1$$


$$h = \frac{\frac{5}{2} - \frac{1}{2}}{1} = 2$$

Dla y0=a


I = h * y0 = 2 * 2 = 4

Dla y0=b


$$I = h*y_{0} = \frac{2}{5}*2 = 0,8$$


$$R = \frac{{(\frac{5}{2} - \frac{1}{2})}^{2}}{2}*1 = 2$$

Metoda trapezów


$$In = \int_{a}^{b}{f\left( x \right)dx = h*\left( \frac{y_{0} + y_{n}}{2} + \sum_{i = 1}^{n - 1}y_{i} \right)}$$


$$h = \frac{b - a}{n}$$


$$R = \frac{{(b - a)}^{3}}{12n^{2}}*\left| f^{''}(\xi) \right|$$


n=2


 xi = x0 + i * h,   i = 1, 2, 3…n


$$h = \frac{\frac{5}{2} - \frac{1}{2}}{2} = 1$$


$$x_{1} = x_{0} + 1*1 = \frac{1}{2} + 1 = 1\frac{1}{2}$$


$$I_{2} = h*\left( \frac{f\left( a \right) + f\left( b \right)}{2} + f\left( x_{1} \right) \right) = 1*\left( \frac{2 + 0,4}{2} + 0,66666 \right) = 1,86666$$


$$R = \frac{{(\frac{5}{2} - \frac{1}{2})}^{3}}{12*2^{2}}*2 = \frac{8*2}{48} = 0,333$$


n=3


$$h = \frac{\frac{5}{2} - \frac{1}{2}}{3} = \frac{2}{3}$$


$$x_{1} = x_{0} + 1*\frac{2}{3} = \frac{1}{2} + 1*\frac{2}{3} = \frac{7}{6}$$


$$x_{2} = x_{0} + 2*\frac{2}{3} = \frac{1}{2} + 2*\frac{2}{3} = 1\frac{5}{6}$$


$$I_{3} = h*\left( \frac{f\left( a \right) + f\left( b \right)}{2} + f\left( x_{1} \right) + f(x_{2}) \right) = \frac{2}{3}*\left( \frac{2 + 0,4}{2} + 0,8571 + 0,54546 \right) = 1,735066$$


$$R = \frac{{(\frac{5}{2} - \frac{1}{2})}^{3}}{12*3^{2}}*2 = \frac{8*2}{108} = 0,148$$


n=4


$$h = \frac{\frac{5}{2} - \frac{1}{2}}{4} = \frac{1}{2}$$


$$x_{1} = x_{0} + 1*\frac{1}{2} = \frac{1}{2} + 1*\frac{1}{2} = 1$$


$$x_{2} = x_{0} + 2*\frac{1}{2} = \frac{1}{2} + 2*\frac{1}{2} = 1\frac{1}{2}$$


$$x_{3} = x_{0} + 3*\frac{1}{2} = \frac{1}{2} + 3*\frac{1}{2} = 2$$


$$I_{4} = h*\left( \frac{f\left( a \right) + f\left( b \right)}{2} + f\left( x_{1} \right) + f\left( x_{2} \right) + f(x_{3)} \right) = \frac{1}{2}*\left( \frac{2 + 0,4}{2} + 1 + 0,6666 + 0,5 \right) = 1,735066$$


$$R = \frac{{(\frac{5}{2} - \frac{1}{2})}^{3}}{12*4^{2}}*2 = \frac{8*2}{192} = 0,0833$$


n=5


$$h = \frac{\frac{5}{2} - \frac{1}{2}}{5} = \frac{2}{5}$$


$$x_{1} = x_{0} + 1*\frac{2}{5} = \frac{1}{2} + 1*\frac{2}{5} = \frac{9}{10}$$


$$x_{2} = x_{0} + 2*\frac{2}{5} = \frac{1}{2} + 2*\frac{2}{5} = \frac{13}{10}$$


$$x_{3} = x_{0} + 3*\frac{1}{2} = \frac{1}{2} + 3*\frac{2}{5} = \frac{17}{10}$$


$$x_{4} = x_{0} + 4*\frac{1}{2} = \frac{1}{2} + 4*\frac{2}{5} = \frac{21}{10}$$


$$I_{5} = h*\left( \frac{f\left( a \right) + f\left( b \right)}{2} + f\left( x_{1} \right) + f\left( x_{2} \right) + f(x_{3)} + f(x_{4}) \right) = \frac{2}{5}*\left( \frac{2 + 0,4}{2} + 1,1111 + 0,76923 + 0,58823 + 0,476190 \right) = 1,735066$$


$$R = \frac{{(\frac{5}{2} - \frac{1}{2})}^{3}}{12*5^{2}}*2 = \frac{8*2}{300} = 0,0533$$


n=6


$$h = \frac{\frac{5}{2} - \frac{1}{2}}{6} = \frac{1}{3}$$


$$x_{1} = x_{0} + 1*\frac{1}{3} = \frac{1}{2} + 1*\frac{1}{3} = \frac{5}{6}$$


$$x_{2} = x_{0} + 2*\frac{1}{3} = \frac{1}{2} + 2*\frac{1}{3} = \frac{7}{6}$$


$$x_{3} = x_{0} + 3*\frac{1}{3} = \frac{1}{2} + 3*\frac{1}{3} = \frac{3}{2}$$


$$x_{4} = x_{0} + 4*\frac{1}{3} = \frac{1}{2} + 4*\frac{1}{3} = \frac{11}{6}$$


$$x_{5} = x_{0} + 5*\frac{1}{3} = \frac{1}{2} + 5*\frac{1}{3} = \frac{13}{6}$$


$$I_{6} = h*\left( \frac{f\left( a \right) + f\left( b \right)}{2} + f\left( x_{1} \right) + f\left( x_{2} \right) + f(x_{3)} + f\left( x_{4} \right) + f(x_{5}) \right) = \frac{1}{3}*\left( \frac{2 + 0,4}{2} + 1,2 + 0,85714 + 0,6666 + 0,545454 + 0,461538 \right) = 1,643597$$


$$R = \frac{{(\frac{5}{2} - \frac{1}{2})}^{3}}{12*6^{2}}*2 = \frac{8*2}{432} = 0,037$$


n=7


$$h = \frac{\frac{5}{2} - \frac{1}{2}}{7} = \frac{2}{7}$$


$$x_{1} = x_{0} + 1*\frac{2}{7} = \frac{1}{2} + 1*\frac{2}{7} = \frac{11}{14}$$


$$x_{2} = x_{0} + 2*\frac{2}{7} = \frac{1}{2} + 2*\frac{2}{7} = \frac{15}{14}$$


$$x_{3} = x_{0} + 3*\frac{2}{7} = \frac{1}{2} + 3*\frac{2}{7} = \frac{19}{14}$$


$$x_{4} = x_{0} + 4*\frac{2}{7} = \frac{1}{2} + 4*\frac{2}{7} = \frac{23}{14}$$


$$x_{5} = x_{0} + 5*\frac{2}{7} = \frac{1}{2} + 5*\frac{2}{7} = \frac{27}{14}$$


$$x_{6} = x_{0} + 6*\frac{2}{7} = \frac{1}{2} + 6*\frac{2}{7} = \frac{31}{14}$$


$$I_{7} = h*\left( \frac{f\left( a \right) + f\left( b \right)}{2} + f\left( x_{1} \right) + f\left( x_{2} \right) + f(x_{3)} + f\left( x_{4} \right) + f\left( x_{5} \right) + f(x_{6}) \right)\ =$$


$$\frac{2}{7}*\left( \frac{2 + 0,4}{2} + 1,272727 + 0,933333 + 0,736842 + 0,608695 + 0,51851 + 0,4516129 \right) = 1,634776$$


$$R = \frac{{(\frac{5}{2} - \frac{1}{2})}^{3}}{12*7^{2}}*2 = \frac{8*2}{588} = 0,027211$$


n=8


$$h = \frac{\frac{5}{2} - \frac{1}{2}}{8} = \frac{1}{4}$$


$$x_{1} = x_{0} + 1*\frac{1}{4} = \frac{1}{2} + 1*\frac{1}{4} = \frac{3}{4}$$


$$x_{2} = x_{0} + 2*\frac{1}{4} = \frac{1}{2} + 2*\frac{1}{4} = 1$$


$$x_{3} = x_{0} + 3*\frac{1}{4} = \frac{1}{2} + 3*\frac{1}{4} = \frac{5}{4}$$


$$x_{4} = x_{0} + 4*\frac{1}{4} = \frac{1}{2} + 4*\frac{1}{4} = \frac{3}{2}$$


$$x_{5} = x_{0} + 5*\frac{1}{4} = \frac{1}{2} + 5*\frac{1}{4} = \frac{7}{4}$$


$$x_{6} = x_{0} + 6*\frac{1}{4} = \frac{1}{2} + 6*\frac{1}{4} = 2$$


$$x_{7} = x_{0} + 7*\frac{1}{4} = \frac{1}{2} + 7*\frac{1}{4} = \frac{9}{4}$$


$$I_{8} = h*\left( \frac{f\left( a \right) + f\left( b \right)}{2} + f\left( x_{1} \right) + f\left( x_{2} \right) + f(x_{3)} + f\left( x_{4} \right) + f\left( x_{5} \right) + f\left( x_{6} \right) + f(x_{7}) \right)\ =$$


$$\frac{1}{4}*\left( \frac{2 + 0,4}{2} + 1,3333 + 1 + 0,8 + 0,6666 + 0,571428 + 0,5 + 0,44444 \right) = 1,628882$$


$$R = \frac{{(\frac{5}{2} - \frac{1}{2})}^{3}}{12*8^{2}}*2 = \frac{8*2}{768} = 0,020833$$


n=9


$$h = \frac{\frac{5}{2} - \frac{1}{2}}{9} = \frac{2}{9}$$


$$x_{1} = x_{0} + 1*\frac{2}{9} = \frac{1}{2} + 1*\frac{2}{9} = \frac{13}{18}$$


$$x_{2} = x_{0} + 2*\frac{2}{9} = \frac{1}{2} + 2*\frac{2}{9} = \frac{17}{18}$$


$$x_{3} = x_{0} + 3*\frac{2}{9} = \frac{1}{2} + 3*\frac{2}{9} = \frac{7}{6}$$


$$x_{4} = x_{0} + 4*\frac{2}{9} = \frac{1}{2} + 4*\frac{2}{9} = \frac{25}{18}$$


$$x_{5} = x_{0} + 5*\frac{2}{9} = \frac{1}{2} + 5*\frac{2}{9} = \frac{29}{18}$$


$$x_{6} = x_{0} + 6*\frac{2}{9} = \frac{1}{2} + 6*\frac{2}{9} = \frac{11}{6}$$


$$x_{7} = x_{0} + 7*\frac{2}{9} = \frac{1}{2} + 7*\frac{2}{9} = \frac{37}{18}$$


$$x_{8} = x_{0} + 8*\frac{2}{9} = \frac{1}{2} + 8*\frac{2}{9} = \frac{41}{18}$$


$$I_{9} = h*\left( \frac{f\left( a \right) + f\left( b \right)}{2} + f\left( x_{1} \right) + f\left( x_{2} \right) + f(x_{3)} + f\left( x_{4} \right) + f\left( x_{5} \right) + f\left( x_{6} \right) + f\left( x_{7} \right) + f(x_{8}) \right)\ =$$


$$\frac{2}{9}*\left( \frac{2 + 0,4}{2} + 1,384615 + 1,0588235 + 0,8571428 + 0,72 + 0,620689 + 0,545454 + 0,486486 + 0,4390243 \right) = 1,6249941$$


$$R = \frac{{(\frac{5}{2} - \frac{1}{2})}^{3}}{12*8^{2}}*2 = \frac{8*2}{972} = 0,016461$$


n=10


$$h = \frac{\frac{5}{2} - \frac{1}{2}}{10} = \frac{1}{5}$$


$$x_{1} = x_{0} + 1*\frac{1}{5} = \frac{1}{2} + 1*\frac{1}{5} = \frac{7}{10}$$


$$x_{2} = x_{0} + 2*\frac{1}{5} = \frac{1}{2} + 2*\frac{1}{5} = \frac{9}{10}$$


$$x_{3} = x_{0} + 3*\frac{1}{5} = \frac{1}{2} + 3*\frac{1}{5} = \frac{11}{10}$$


$$x_{4} = x_{0} + 4*\frac{1}{5} = \frac{1}{2} + 4*\frac{1}{5} = \frac{13}{10}$$


$$x_{5} = x_{0} + 5*\frac{1}{5} = \frac{1}{2} + 5*\frac{1}{5} = \frac{3}{2}$$


$$x_{6} = x_{0} + 6*\frac{1}{5} = \frac{1}{2} + 6*\frac{1}{5} = \frac{17}{10}$$


$$x_{7} = x_{0} + 7*\frac{1}{5} = \frac{1}{2} + 7*\frac{1}{5} = \frac{19}{10}$$


$$x_{8} = x_{0} + 8*\frac{1}{5} = \frac{1}{2} + 8*\frac{1}{5} = \frac{21}{10}$$


$$x_{9} = x_{0} + 9*\frac{1}{5} = \frac{1}{2} + 9*\frac{1}{5} = \frac{23}{10}$$


$$I_{10} = h*\left( \frac{f\left( a \right) + f\left( b \right)}{2} + f\left( x_{1} \right) + f\left( x_{2} \right) + f(x_{3)} + f\left( x_{4} \right) + f\left( x_{5} \right) + f\left( x_{6} \right) + f\left( x_{7} \right) + f\left( x_{8} \right) + f(x_{9}) \right)\ $$


$$= \frac{1}{5}*\left( \frac{2 + 0,4}{2} + 1,42857 + 1,11111 + 0,909090 + 0,7692308 + 0,66666 + 0,5882352 + 0,52631579 + 0,476190 + 0,4347826 \right) = 1,622168$$


$$R = \frac{{(\frac{5}{2} - \frac{1}{2})}^{3}}{12*8^{2}}*2 = \frac{8*2}{1200} = 0,01333$$

Metoda Simpsona


$$In = \int_{a}^{b}{f\left( x \right)dx = \frac{h}{3}*\left( y_{0} + 4*y_{1} + 2*y_{2} + 4*y_{3} + \ldots 2*y_{n - 2} + 4*y_{n} \right)}$$


$$R = \frac{({b - a)}^{5}}{n}*\left| f(\xi) \right|$$


xi = i * h

n=2


$$x_{1} = \frac{1}{2} + 1*1 = 1\frac{1}{2}$$


$$h = \frac{b - a}{n} = \frac{\frac{5}{2} - \frac{1}{2}}{2} = 1$$


$$I_{2} = \frac{1}{3}*\left( f\left( a \right) + 4*(x_{1} \right) + f\left( b \right) = 0,333*\left( 2 + 4*0,6666 + 0,4 \right) = 1,688886$$


$$R = \frac{{(2,5 - 0,5)}^{5}}{180*2^{4}} = \frac{32}{180*16} = 0,264$$

n=4


$$x_{1} = \frac{1}{2} + 1*\frac{1}{2} = 1$$


$$x_{2} = \frac{1}{2} + 2*\frac{1}{2} = \frac{3}{2}$$


$$x_{3} = \frac{1}{2} + 3*\frac{1}{2} = 2$$


$$x_{4} = \frac{1}{2} + 4*\frac{1}{2} = \frac{5}{2}$$


$$h = \frac{b - a}{n} = \frac{\frac{5}{2} - \frac{1}{2}}{4} = \frac{1}{2}$$


$$I_{4} = \frac{1}{6}*\left( f\left( a \right) + 4*f(x_{1} \right) + 2*f\left( x_{2} \right) + 4*f\left( x_{3} \right) + 2*f(x_{4}) + f\left( b \right) = 0,16666*\left( 2 + \left( 4*1 \right) + \left( 2*0,6666667 \right) + \left( 4*0,5 \right) + (2*0,4) + 0,4 \right) = 1,755485$$


$$R = \frac{{(2,5 - 0,5)}^{5}}{180*4^{4}}*24 = \frac{32}{180*256} = 0,01666$$

n=6


$$x_{1} = \frac{1}{2} + 1*\frac{1}{3} = \frac{5}{6}$$


$$x_{2} = \frac{1}{2} + 2*\frac{1}{3} = \frac{7}{6}$$


$$x_{3} = \frac{1}{2} + 3*\frac{1}{3} = \frac{3}{2}$$


$$x_{4} = \frac{1}{2} + 4*\frac{1}{3} = \frac{11}{6}$$


$$x_{5} = \frac{1}{2} + 5*\frac{1}{3} = \frac{13}{6}$$


$$x_{6} = \frac{1}{2} + 6*\frac{1}{3} = \frac{5}{2}$$


$$h = \frac{b - a}{n} = \frac{\frac{5}{2} - \frac{1}{2}}{6} = \frac{1}{3}$$


$$I_{6} = \frac{1}{9}*\left( f\left( a \right) + 4*f(x_{1} \right) + 2*f\left( x_{2} \right) + 4*f\left( x_{3} \right) + 2*f\left( x_{4} \right) + 4*f\left( x_{5} \right) + 2*f\left( x_{6} \right) + f\left( b \right)$$


=0, 1111111   * (2+(4*1,2)+(2*0,85714)+(4*0,66666)+(2*0,545454)+(4*0,461538)+(2*0,4)+0,4) = 1, 701998


$$R = \frac{{(2,5 - 0,5)}^{5}}{180*6^{4}}*24 = \frac{32}{180*1296} = 0,0032$$

n=8


$$x_{1} = \frac{1}{2} + 1*\frac{1}{4} = \frac{3}{4}$$


$$x_{2} = \frac{1}{2} + 2*\frac{1}{4} = 1$$


$$x_{3} = \frac{1}{2} + 3*\frac{1}{4} = \frac{5}{4}$$


$$x_{4} = \frac{1}{2} + 4*\frac{1}{4} = \frac{3}{2}$$


$$x_{5} = \frac{1}{2} + 5*\frac{1}{4} = \frac{7}{4}$$


$$x_{6} = \frac{1}{2} + 6*\frac{1}{4} = 2$$


$$x_{7} = \frac{1}{2} + 7*\frac{1}{4} = \frac{9}{4}$$


$$x_{8} = \frac{1}{2} + 8*\frac{1}{4} = \frac{5}{2}$$


$$h = \frac{b - a}{n} = \frac{\frac{5}{2} - \frac{1}{2}}{8} = \frac{1}{4}$$


$$I_{8} = \frac{1}{12}*\left( f\left( a \right) + 4*f(x_{1} \right) + 2*f\left( x_{2} \right) + 4*f\left( x_{3} \right) + 2*f\left( x_{4} \right) + 4*f\left( x_{5} \right) + 2*f\left( x_{6} \right) + 4*f\left( x_{7} \right) + 2*f\left( x_{8} \right) + f\left( b \right)$$


=0, 083333   * (2+(4*1,3333)+(2*1)+(4*0,8)+(2*0,66666)+(4*0,57142)+(2*0,5)+(4*0,44444)+(2*0,4)+0,4) = 1, 67749


$$R = \frac{{(2,5 - 0,5)}^{5}}{180*8^{4}}*24 = \frac{32}{180*1296} = 0,00104$$

n=10


$$x_{1} = \frac{1}{2} + 1*\frac{1}{5} = \frac{7}{10}$$


$$x_{2} = \frac{1}{2} + 2*\frac{1}{5} = \frac{9}{10}$$


$$x_{3} = \frac{1}{2} + 3*\frac{1}{5} = \frac{11}{10}$$


$$x_{4} = \frac{1}{2} + 4*\frac{1}{5} = \frac{13}{10}$$


$$x_{5} = \frac{1}{2} + 5*\frac{1}{5} = \frac{3}{2}$$


$$x_{6} = \frac{1}{2} + 6*\frac{1}{5} = \frac{17}{10}$$


$$x_{7} = \frac{1}{2} + 7*\frac{1}{5} = \frac{19}{10}$$


$$x_{8} = \frac{1}{2} + 8*\frac{1}{5} = \frac{21}{10}$$


$$x_{9} = \frac{1}{2} + 9*\frac{1}{5} = \frac{23}{10}$$


$$x_{10} = \frac{1}{2} + 10*\frac{1}{5} = \frac{5}{2}$$


$$h = \frac{b - a}{n} = \frac{\frac{5}{2} - \frac{1}{2}}{10} = \frac{1}{5}$$


$$I_{8} = \frac{1}{15}*\left( f\left( a \right) + 4*f(x_{1} \right) + 2*f\left( x_{2} \right) + 4*f\left( x_{3} \right) + 2*f\left( x_{4} \right) + 4*f\left( x_{5} \right) + 2*f\left( x_{6} \right) + 4*f\left( x_{7} \right) + 2*f\left( x_{8} \right) + 4*f\left( x_{9} \right) + 2*f\left( x_{10} \right) + f\left( b \right)$$


=0, 066666   * (2+(4*1,42857)+(2*1,11111)+(4*0,909090)+(2*0,769230)+(4*0,66666)+(2*0,588235)+(4*0,526316)+(2*0,47619)+(4*0,43478)+(2*0,4)+0,4) = 1, 663396


$$R = \frac{{(2,5 - 0,5)}^{5}}{180*8^{4}}*24 = \frac{32}{180*10000} = 0,00042$$

Wnioski :

Zadanie to pozwoliło nam na zapoznanie się z trudnościami obliczania całki różnymi metodami numerycznymi . Poznaliśmy zarówno wady jak i zalety poszczególnych metod. Metodą Simpsona można tylko dzielić przedział na parzyste liczby, w przeciwnym wypadku wyniki wyjdą nieprawidłowe.


Wyszukiwarka

Podobne podstrony:
Calkowanie numeryczne, WIP AIR, SEM 1, TEINF, TEINF, Teinf projekty
całkowanie numeryczne
Calkowanie numeryczne
Wykład 8-Całkowanie numeryczne. Kwadratury Newtona-Cotesa
1 Metody całkowania numerycznego 1 1
Całkowanie numeryczne
Calkowanie numeryczne pdf
calkowanie numeryczne
sciaga malek 24-25, Algorytmy wielokrotnego całkowania numeryczne
Całkowanie numeryczne, Studia, ZiIP, SEMESTR III, Metody numeryczne
Całkowanie numeryczne metoda trapezów mini, Studia, ZiIP, SEMESTR III, Metody numeryczne
Całkowanie numeryczne
Wykład 9- Całkowanie numeryczne.Kwadratury Gaussa
całkowanie numeryczne
1 Metody całkowania numerycznego 2id 8579
Calkowanie numeryczne 2009
Calkowanie numeryczne
Calkowanie numeryczne, WIP AIR, SEM 1, TEINF, TEINF, Teinf projekty

więcej podobnych podstron