.


:




:

































 

 

 

 


[a,b]




.

: , .

[a,b], (.4.1), n (n = 4), xi = a+h*i-h/2; h = (b-a)/n.

si=h*f(xi). si : .

, , . n , .. n = 2n. .

.4.1

e, |S1 - S2|<e. , S2 ; , S2 , .. S1 = S2. S2. n S2 , S1 S2 e.

4.1. .

#include <iostream>

#include <conio.h>

#include <math.h>

using namespace std;

 

#define Pi 3.14159

 

int main()

{unsigned long i, n = 4;

float a,b,x,h,S1,S2,eps,exact;

a = 0; b = 3/(2*Pi); eps = 0.001;

S1 = 0;

h = (b a)/n;

//

for (i = 1; i<=n; i++)

{ x = a + i*h h/2;

S1 = S1+ (1/(53*cos(x)))*h;

}

//

do {n = 2*n;

h = (b a)/n;

S2 = 0;

for (i = 1; i<=n; i++)

{x = a + i*h h/2;

S2 = S2 + (1/(53*cos(x)))*h;

}

exact = fabs(S1 S2);

S1 = S2;

} while(exact>eps);

cout << "S = " << S2;

return 0;

}

[a,b]

, (.4.2). a b - ; xi = a + i(b - a)/n.

[a,b] n () .

:

n - ; xi = a + i(b a)/n.

f(xi). f(a) f(b) , 4, - 2. .

.4.2. .

4.2. .

#include <iostream>

#include <conio.h>

#include <math.h>

using namespace std;

 

int main()

{unsigned long i, n;

float a,b,x,h,y,s;

cout << " -> ";

cin >> n;

a = 0; b = 1.8;

s = 0; x = a;

h = (b a)/n;

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

{ y = (1/(1+sqrt(x));

x = x + h;

if (i % 2!= 0) s = s + 4*y;

else if (i == 0 || i == n) s = s + y;

else s = s + 2*y;

}

s*=h/3;

cout << "S = " << s;

}

e F(x)=0

[a,b] (.4.3). F(x) = 0 x = f(x). x = x1, x = f(x), x2 = f(x1).
x3 = f(x2),..., xk+1 = f(xk).

, |f(x)|<1 , . 1<f ΄(x)<0, [xk, xk+1] [xk+1,xk] [xk+1 xk]<e.

.4.3.

F(x) = 0 f(x) . F(x) = 0 h x. :

hF(x) + x = 0*h + x;

hF(x) + x = x.

f(x) = hF(x) + x, x = f(x). h , |f '(x)|<1, f '(x)<0 , .

, , . |xg x t|<e, xt

4.3. .

.

#include <iostream>

#include <conio.h>

#include <math.h>

using namespace std;

 

int main()

{ float xt, xg = 2.3, eps = 0.001, x = 5*eps;

int step = 0;

while (fabs(x)>=eps)

{ xt = -0.2*(xg*xg*xg 2*xg*xg 3)+xg;

x = xt-xg;

step++;

xg = xt;

}

cout << " = " << xt << " " << step;

getch();

return 0;

}


f(x) = 0 e





:


: 2016-12-06; !; : 407 |


:

:

, .
==> ...

1789 - | 1697 -


© 2015-2024 lektsii.org - -

: 0.019 .