.


:




:

































 

 

 

 





, ; , :

x, y, z ( !!!) à x, y, z ;

, , , .. ε ().

 

.

:

( , (), ..),

( ( ), ..)

 

, , (1) (2,...) , :

for (1=..., 2=...; (1,2); 2=1,1=)

{... = f (x 1, x 2);...}

 

, = √ , : yk=(yk-1 + x/yk-1)/2 k = 1, 2,.


, Ynew, Yold;
epsilon;
X, epsilon; //
epsilon
Yold = X;
Ynew = (Yold + X/ Yold)/2;
(abs (Ynew Yold) >= epsilon)

Yold= Ynew;
Ynew= (Yold + X/ Yold)/2;

Ynew;

 

-----------------------------------------------------------------------------------------

 

π.

π/4 =1-1/3+1/5-1/7+1/9-.

π = 4 * π/4;

 

:

                 
 
 
 

 

 


#define _USE_MATH_DEFINES

#include <math.h>

#include <iostream> // / ++

#include <iomanip>

using namespace std; //

 

int main()

{

int k = 1;

double x = 1.0, sum = x, eps = 0.000001;

while (abs(x) > eps)

{

x = -x *(2 * k - 1)/(2 * k + 1);

sum += x;

k++;

}

cout << setiosflags(ios::fixed) << setprecision(7);

cout << "summa:" << setw(11) << sum << endl;

cout << endl;

cout << "PI:" << setw(11) << sum * 4 << endl;

system("pause");

return 0;

}

 

#include <iomanip> , :

  • setw(n) n ;
  • setprecision(m) m ( );
  • setiosflags(ios:: fixed) - ;
  • setiosflags(ios:: scientific) - .

:
summa: 0.7853987

 

PI: 3.1415947

, eps = 0.00000 1.

-----------------------------------------------------------------------------------------





:


: 2018-10-15; !; : 154 |


:

:

, .
==> ...

1522 - | 1427 -


© 2015-2024 lektsii.org - -

: 0.013 .