.


:




:

































 

 

 

 





.

- , ξ, z, ..

n , () n : , , , , ..

.

ξ, η i η . :

, (1)

, .

- , , . . , . , (), . , , .

:

 

1. n.

2. .

3. .

4. ( ) x y.

5. x y , .

6. 4 5 n .

7. ( 1) (1) .

 

.

 

n
DInt
F
x, y
S ()
Ax, Ay, Bx, By
i

 

MonteKarlo WinCrt, Strings. MonteKarlo -, : function F(x,y: real): real; - function DInt(A: real; n: longint): real; - .

 

.

 

MonteKarlo.pas. .

 

program MonteKarlo;

uses WinCrt,Strings;

 

{ }

function F(x,y: real): real;

begin

F:= exp(x+y)+exp(x-y)*sin(x);

end;

 

{ }

function DInt(n: longint): real;

var

S, x, y, Ax, Ay, Bx, By: real;

i: longint;

begin

randomize;

Ax:= 0; Bx:= 4; Ay:= 1; By:=5;

S:=0;

for i:= 1 to n do begin

x:= Ax+random*(Bx-Ax);

y:= Ay+random*(By-Ay);

if ((x>=0) and (x<=4))and((y>=1) and (y<=5)) then S:= F(x,y)+S;

end;

DInt:= (Bx-Ax)*(By-Ay)*S/n;

end;

 

var

a: real;

n: longint;

 

BEGIN

StrCopy(WindowTitle, ' -');

ClrScr;

WriteLn;

WriteLn(' 5 4');

WriteLn(' / / ');

WriteLn(' | | (exp(x+y)+exp(x-y)*sin(x)dxdy');

WriteLn(' / / ');

WriteLn(' 1 0');

WriteLn;

WriteLn;

WriteLn;

Write(' n = ');

ReadLn(n);

WriteLn;

WriteLn;

WriteLn(' , ...');

WriteLn;

WriteLn;

WriteLn(' :');

WriteLn;

WriteLn(' I = ',DInt(n):10:4);

ReadKey;

DoneWinCrt;

END.

 

Run Run Ctrl+F9, :

 

 

 

n. .

.





:


: 2016-07-29; !; : 422 |


:

:

, .
==> ...

1881 - | 1698 -


© 2015-2024 lektsii.org - -

: 0.011 .