2- masala. (2.42) formula yordamida integrallash sohasi D: x=0, x=4, y=3x, y=8x chiziqlar bilan chegaralangan quyidagi integralni hisoblang
Bu integralni integrallash sohasi D (8.13- rasm) ga asosan karrali integralga o‘tkazamiz:
bu yerda a=0, b=4, 1(x)=3x, 2(x)=8x shuningdek 1(x)0, 2(x)32 bundan s=0, d=32.
Integral ostidagi funktsiya uchun:
quyidagicha x=4, y=32, z=6 almashtirish qilsak (8.14 rasm)
Tasodifiy sonlardan 60 tasini olamiz (N=20). Bu holda hisoblash jadvalidan i< (2.43) shartni qanoatlantiruvchilarga mos kelgan z1i (2.44) shartni qanoatlantruvchilar sonini n ni aniqlaymiz.
Demak, n=4. (2.42) formulaga asosan:
Aniq yechim:
Xatolik
2-masalani Monte-Karlo usulida ikkilangan integralni
formula asosida hisoblash dasturi(Basic tilida):
DEF FNF (X, y) = SQR(X + y)
DEF FNF1 (X) = 3 * X
DEF FNF2 (X) = 8 * X
DIM X(100), xT(100), y(100), Z(100), ZT(100), y1(100), y2(100), yT(100)
DIM xTT(100), yTT(100), ZTT(100)
N1 = 0: N2 = 0: N3 = 0: INPUT "N="; N: INPUT "Ac = FNF1(a): d = FNF2(b): PRINT "c="; c, "d="; d
'INPUT "C=f1(a),B=f2(b) "; c, d
'INPUT "M= "; M
M = FNF(b, d): PRINT "m="; M
INPUT "Y=1"; y: IF y = 1 THEN 28
FOR I = 1 TO N
X(I) = a + (b - a) * RND(1): y(I) = c + (d - c) * RND(1): Z(I) = M * RND(1)
y1(I) = FNF1(X(I)): y2(I) = FNF2(X(I)): NEXT I
PRINT " xi yi zi y1(i) y2(i) FNF(xi, yi)"
FOR I = 1 TO N
PRINT USING "###.#####"; X(I); y(I); Z(I); y1(I); y2(I); FNF(X(I), y(I)): NEXT I
FOR I = 1 TO N
'IF y1(I) < y(I) AND y(I) < y2(I) THEN IF Z(I) < FNF(X(I), y(I)) THEN N1 = N1 + 1: xT(N1) = X(I): yT(N1) = y(I): ZT(N1) = Z(I)
IF y1(I) < y(I) AND y(I) < y2(I) THEN N1 = N1 + 1: xT(N1) = X(I): yT(N1) = y(I): ZT(N1) = Z(I)
NEXT I: PRINT "N1="; N1
INPUT "Y=1"; y: IF y = 1 THEN 73
FOR I = 1 TO N1
PRINT USING "####.#####"; xT(I); yT(I); ZT(I); FNF(xT(I), yT(I))
NEXT I: PRINT
FOR I = 1 TO N1
IF ZT(I) < FNF(xT(I), yT(I)) THEN N2 = N2 + 1: xTT(N2) = xT(I): yTT(N2) = yT(I): ZTT(I) = ZT(I)
NEXT I: PRINT "N2="; N2
PRINT " xtT(i) ytT(i) ztT(i) FNF(xtT(I), ytT(I))"
FOR I = 1 TO N2
PRINT USING "####.#####"; xT(I); yT(I); ZT(I); FNF(xT(I), yT(I))
'S = S + FNF(xT(I), yT(I))
NEXT I
PRINT "w="; (b - a) * (d - c)
s1 = (b - a) * (d - c) * N2 * M / N: PRINT " S1="; s1
N=10
A
Do'stlaringiz bilan baham: |