:  :
:   
 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 




:

:

:

-

-1-12

.

:

. .

2001

1. :

, , . , , . .

I=ò f(x)dx, f(x) , . I , x=a, x=b, y=0, y=f(x). - n [a,b] n x0=a<x1<<xn=b. x=xi n . (. 1, n=4).


. 1

((f(x0)+f(x1))/2)*(x1-x0)=((y0+y1)/2)*((b-a)/n),

, , f(x0)=y0 f(x1)=y1,

x1-x0=(b-a)/n.

(y1+y2)*((b-a)/2*n), (y2+y3)*((b-a)/2*n), , (yn-1+yn)*((b-a)/2*n).

,

I((b-a)/2*n)*[y0+2*(y1++yn-1)+yn].

y0+yn=Y (), y1+y2++yn-1=Y (),

ò ydx ((b-a)/2* n)*(Y+2*Y)


ò f(x)dx (h/2)*[f(a)+f(b)+2åf(xi)]

( h n , xi=a+i*h). . , n. : -(h^3)/12.

. f(x) = x³ +2x²-3x-8 [0, 6]. .

, . main, f trap. main , trap . f x float . Trap : , . Trap : float (a b), float . , , | S-Sn |, . , . . , S0 S1=S1+f(a+(2*i+1)*h), . , , , , .

-, , , . - , trap, - , .

2. - :










i=1

S1=S1+f(a+(2*i+1)*h)


i=n/2





3. :

#include<stdio.h>

#include<math.h>

#include<conio.h>

main()

{

double a,b,er,eps,f(double),s,trap(double,double,double,double(*)(double));

clrscr();

printf("\n : ");

scanf ("%lf%lf%lf",&a,&b,&eps);

s=trap(a,b,eps,f);

printf("\n a=%3.2lf b=%3.2lf %lf",a,b,s);

getch();

}

double f(double x)

{

return x*x*x+2*(x*x)-3*x-8;

}

double trap(double a,double b,double eps,double(*f)(double))

{

double h,s,s0,s1,sn;

int i,n;

s=1; sn=101;

n=4;

s0=(f(a)+f(b))/2;

s1=f((a+b)/2);

while(fabs(s-sn)>eps){

sn=s;

h=(b-a)/n;

for(i=0; i<n/2; i++)

s1+=f(a+(2*i+1)*h);

s=h*(s0+s1);

n*=2;

}

return s;

}

4. :

n
int
[a, b]
i
int
a
double
b
double
h
double
eps
double
f
double(*)
-
x
double
- f
s
double
s0
double
a b
s1
double

sn
double

5. :

Xi
Yi
0
-8
0,75
-8,703125
1,5
-4,625
2,25
6,765625
3
28
3,75
61,609375
4,5
110,125
5,25
176,078125
6
262




6. :

eps = 0.1 eps = 0.001







a, b, eps: a, b, eps:

0 0

6 6

.1 .001

= 366.024170 = 366.000094



. 1/10000.



      ©2010