Uploaded by bek1848

ALGORITMLARNI LOYIHALASH

advertisement
ALGORITMLARNI LOYIHALASH
Oraliqni teng 2 ga bo’lish usuliga oid masalalar.
1-savol.
๐‘ฅ 3 + ๐‘ฅ − 1 = 0 tenglamaning (0;1) oraliqdagi ildizini oraliqni teng ikkiga bo’lish usuli bo’yicha izlanayotgan
bo’lsa 2 qadamdan keyin qanday qoladi?
A. (0;0.25)
B. (0.25;0.5)
C. (0.5;0.75)
D. (0.75;1)
Oraliqni teng 2 ga bo’lish usuli xatolikka qarab berilgan oraliqni teng 2 ga bo’lib taqribiy yechimga
yaqinlashtirilib boriladi.
f(x) = ๐‘ฅ 3 + ๐‘ฅ − 1 funksiyani tekshirib boramiz.
1-qadam:
Umumiy oraliq (0; 1) -> teng ikkitaga ajratsak (0; 0.5) va (0.5; 1)
Left = 0; right = 1; middle = (left+right)/2 = 0.5
Left: f(0) = 03 + 0 – 1 = -1 (manfiy)
Right: f(1) = 13 + 1 – 1 = 1 (musbat)
Middle: f(0.5) = 0.53 + 0.5 – 1 = -0.375 (manfiy)
0
0.5
1
manfiy
manfiy
musbat
Ishorasi almashadigan oraliqni tanlaymiz keyingi oraliq uchun.
(0; 0.5) -> (manfiy; manfiy)
=> xato
(0.5; 1) -> (manfiy; musbat) => to’g’ri (yechim shu oraliqda)
Demak ikkinchi qadamda (0.5; 1) oraliqdan izlaymiz.
2-qadam:
Umumiy oraliq (0.5; 1) -> teng ikkitaga ajratsak (0.5; 0.75) va (0.75; 1)
Left = 0.5; right = 1; middle = (left+right)/2 = 0.75
Left: f(0.5) = 0.53 + 0.5 – 1 = -0.375 (manfiy)
Right: f(1) = 13 + 1 – 1 = 1 (musbat)
Middle: f(0.75) = 0.753 + 0.75 – 1 = 0.171875 (musbat)
0.5
0.75
1
manfiy
musbat
musbat
Ishorasi almashadigan oraliqni tanlaymiz keyingi oraliq uchun.
(0.5; 0.75) -> (manfiy; musbat) => to’g’ri (yechim bor)
(0.75; 1) -> (musbat; musbat)
=> xato (yechim mavjud emas bu oraliqda)
Demak ikkinchi qadamda (0.5; 0.75) oraliqda yechim mavjudligini bildik. 2-qadam oxirida shu (0.5;
0.75) oraliq qolyapti.
To’g’ri javob (0.5; 0.75)
Xuddi shu usul bo’yicha
2-savol
๐‘ฅ 4 − ๐‘ฅ − 1 = 0 tenglamaning (-1;0) oraliqdagi ildizini oraliqni teng ikkiga bo’lish usuli bo’yicha izlanayotgan
bo’lsa 2 qadamdan keyin qanday qoladi?
A. (-0.75;-0.5)
B. (-0.5;-0.25)
C. (-1;-0.75)
D. (-0.25;0)
f(x) = x4 – x – 1 uchun (-1; 0) oraliqda 2 ta qadamdan keyin …
1-qadam:
Umumiy oraliq (-1; 0). 2 ga ajratsak (-1; -0.5) va (-0.5; 0)
f(-1) -> musbat
f(-0.5) -> manfiy
f(0) -> manfiy
(-1; -0.5)
=>
(musbat; manfiy) yechim mavjud.
(-0.5; 0)
=>
(manfiy; manfiy) yechim mavjud emas
Demak (-1; -0.5) oraliqni olamiz.
2-qadam:
Umumiy oraliq (-1; -0.5). 2 ga ajratsak (-1; -0.75) va (-0.75; -0.5)
f(-1) -> musbat
f(-0.75) -> musbat
f(-0.5) -> manfiy
Demak:
(-1; -0.75)
=>
(musbat; musbat) bu oraliqda yechim mavjud emas.
(-0.75; -0.5)
=>
(musbat; manfiy) Yechim mavjud.
Javob: 2-qadamdan keyin (-0.75; -0.5) oraliq qolyapti.
Nyuton usuliga oid savollar
Nazariyacha.
Nyuton usulida:
a) Agar ๐‘“(๐‘Ž)๐‘“ ′′ (๐‘Ž) > 0 bo’lsa ๐‘ฅ0 = ๐‘Ž
b) Agar ๐‘“(๐‘Ž)๐‘“ ′′ (๐‘Ž) < 0 bo’lsa ๐‘ฅ0 = ๐‘ deb olinadi
๐’‡(๐’™๐’ )
๐’‡′ (๐’™๐’ )
formula bilan hisoblanadi. Bunda ham yaqinlashtirish jarayoni |๐‘ฅ๐‘›+1 − ๐‘ฅ๐‘› | ≤ ๐œ€ shart bajarilmaguncha
davom etadi.
๐’™๐’+๐Ÿ = ๐’™๐’ −
3-savol
๐‘ฅ 4 − ๐‘ฅ − 1 = 0 tenglamaning (-1;0) oraliqdagi ildizini Nyuton usuli bo’yicha izlaganda hisoblash formulasi
qanday bo’ladi?
A. ๐‘ฅ๐‘›+1 =
B. ๐‘ฅ๐‘›+1 =
C. ๐‘ฅ๐‘›+1 =
D. ๐‘ฅ๐‘›+1 =
4 +๐‘ฅ +1
3๐‘ฅ๐‘›
๐‘›
; (shu javob sal yaqin)
3 −1
4๐‘ฅ๐‘›
4
3๐‘ฅ๐‘› +2๐‘ฅ๐‘› +1
3 −1
4๐‘ฅ๐‘›
4
3๐‘ฅ๐‘› +3๐‘ฅ๐‘› +1
3 −1
4๐‘ฅ๐‘›
4
2๐‘ฅ๐‘› +๐‘ฅ๐‘› +1
3 −1
4๐‘ฅ๐‘›
;
;
;
Bu savolda xatolik bor. Bu yilgi savollarda xatolar to’g’rilangan.
Umumiy formulasi: ๐’™๐’+๐Ÿ = ๐’™๐’ −
๐’‡(๐’™๐’ )
๐’‡′ (๐’™)
๐‘“(๐‘ฅ) = ๐‘ฅ 4 − ๐‘ฅ − 1 , bundan hosila olsak ๐’‡′ (๐’™) = ๐Ÿ’๐’™๐Ÿ‘ − ๐Ÿ
๐‘“(๐‘ฅ๐‘› )
๐‘ฅ๐‘›4 − ๐‘ฅ๐‘› − 1
๐‘ฅ๐‘› (4๐‘ฅ๐‘›3 − 1) − (๐‘ฅ๐‘›4 − ๐‘ฅ๐‘› − 1)
3๐‘ฅ๐‘›4 + 1
๐‘ฅ๐‘›+1 = ๐‘ฅ๐‘› − ′
= ๐‘ฅ๐‘› −
=
=
๐‘“ (๐‘ฅ)
4๐‘ฅ๐‘›3 − 1
4๐‘ฅ๐‘›3 − 1
4๐‘ฅ๐‘›3 − 1
4-savol
๐‘ฅ 3 + ๐‘ฅ − 1 = 0 tenglamaning (0;1) oraliqdagi ildizini Nyuton usuli bo’yicha izlaganda hisoblash formulasi
qanday bo’ladi?
A. ๐‘ฅ๐‘›+1 =
B. ๐‘ฅ๐‘›+1 =
C. ๐‘ฅ๐‘›+1 =
D. ๐‘ฅ๐‘›+1 =
3 −๐‘ฅ +1
2๐‘ฅ๐‘›
๐‘›
; (sal xatosi bor yaqin javob)
2 +1
3๐‘ฅ๐‘›
3 −2๐‘ฅ +1
2๐‘ฅ๐‘›
๐‘›
3 +1
3๐‘ฅ๐‘›
3
3๐‘ฅ๐‘› −2๐‘ฅ๐‘› +1
2 +1
3๐‘ฅ๐‘›
3
๐‘ฅ๐‘› +๐‘ฅ๐‘› −2
2 +1
3๐‘ฅ๐‘›
;
;
;
Xuddi shu usulda ishlasak:
๐‘“(๐‘ฅ) = ๐‘ฅ 3 + ๐‘ฅ − 1 bundan hosila olsak ๐’‡′ (๐’™) = ๐Ÿ‘๐’™๐Ÿ + ๐Ÿ
๐‘“(๐‘ฅ๐‘› )
๐‘ฅ๐‘› 3 + ๐‘ฅ๐‘› − 1
๐‘ฅ๐‘› (3๐‘ฅ๐‘› 2 + 1) − (๐‘ฅ๐‘› 3 + ๐‘ฅ๐‘› − 1)
2๐‘ฅ๐‘›3 + 1
๐‘ฅ๐‘›+1 = ๐‘ฅ๐‘› − ′
= ๐‘ฅ๐‘› −
=
=
๐‘“ (๐‘ฅ)
3๐‘ฅn 2 + 1
3๐‘ฅ๐‘› 2 + 1
3๐‘ฅ๐‘› 2 + 1
Vatarlar usuliga oid savollar tahlili
Bunga oid 4 ta nazariy (1 tasi tushishi mumkin) va kamida 1 ta masala bor.
๐‘“(๐‘ฅ) = 0 tenglamaning (a; b) oraliqdagi ildizini topishning vatarlar usuli.
1) Agar ๐‘“ ′ (๐‘ฅ)๐‘“ ′′ (๐‘ฅ) > 0 bo’lsa ๐‘ฅ0 = ๐‘Ž hamda b nuqta qo’zga’lmas bo’ladi. xn+1 esa quyidagicha: ๐‘ฅ๐‘›+1 =
๐‘“(๐‘ฅ )(๐‘−๐‘ฅ )
๐‘›
๐‘›
๐‘ฅ๐‘› − ๐‘“(๐‘)−๐‘“(๐‘ฅ
)
๐‘›
2) Agar ๐‘“ ′ (๐‘ฅ)๐‘“ ′′ (๐‘ฅ) < 0 bo’lsa ๐‘ฅ0 = b hamda a nuqta qo’zga’lmas bo’ladi. xn+1 esa quyidagicha: ๐‘ฅ๐‘›+1 =
๐‘“(๐‘ฅ )(a−๐‘ฅ )
๐‘›
๐‘›
๐‘ฅ๐‘› − ๐‘“(a)−๐‘“(๐‘ฅ
)
๐‘›
Eslab qoling:
0 dan katta bo’lsa x0 = a,
b esa qo’zgalmas
0 dan kichik bo’lsa x0 = b,
a esa qo’zg’almas
5-savol
๐‘“(๐‘ฅ) = 0 tenglamaning (a; b) oraliqdagi ildizini topishda ๐‘“ ′ (๐‘ฅ)๐‘“ ′′ (๐‘ฅ) > 0 shart bajarilsa vatarlar usuli
formulasi qanday ko’rinishda bo’ladi?
๐‘“(๐‘ฅ๐‘› )(๐‘−๐‘ฅ๐‘› )
A. ๐‘ฅ๐‘›+1 = ๐‘ฅ๐‘› − ๐‘“(๐‘)−๐‘“(๐‘ฅ
; ๐‘ฅ0 = ๐‘Ž
)
๐‘›
B.
C.
D.
๐‘“(๐‘ฅ๐‘› )(๐‘Ž−๐‘ฅ๐‘› )
๐‘ฅ๐‘›+1 = ๐‘ฅ๐‘› − ๐‘“(๐‘Ž)−๐‘“(๐‘ฅ
; ๐‘ฅ0 = ๐‘
๐‘›)
๐‘“(๐‘ฅ )
๐‘ฅ๐‘›+1 = ๐‘ฅ๐‘› − ๐‘“′ (๐‘ฅ๐‘› ) ; ๐‘ฅ0 = ๐‘
๐‘›
๐‘“(๐‘ฅ )
๐‘ฅ๐‘›+1 = ๐‘ฅ๐‘› − ๐‘“′ (๐‘ฅ๐‘› ) ;
๐‘›
๐‘ฅ0 = ๐‘Ž
6-savol
๐‘“(๐‘ฅ) = 0 tenglamaning (a;b) oraliqdagi ildizini topishda ๐‘“ ′ (๐‘ฅ)๐‘“ ′′ (๐‘ฅ) < 0 shart bajarilsa vatarlar usuli
formulasi qanday ko’rinishda bo’ladi?
๐‘“(๐‘ฅ๐‘› )(๐‘Ž−๐‘ฅ๐‘› )
A. ๐‘ฅ๐‘›+1 = ๐‘ฅ๐‘› − ๐‘“(๐‘Ž)−๐‘“(๐‘ฅ
; ๐‘ฅ0 = ๐‘
)
๐‘›
B.
C.
D.
๐‘“(๐‘ฅ๐‘› )(๐‘−๐‘ฅ๐‘› )
๐‘ฅ๐‘›+1 = ๐‘ฅ๐‘› − ๐‘“(๐‘)−๐‘“(๐‘ฅ
; ๐‘ฅ0 = ๐‘Ž
๐‘›)
๐‘“(๐‘ฅ )
๐‘ฅ๐‘›+1 = ๐‘ฅ๐‘› − ๐‘“′ (๐‘ฅ๐‘› ) ; ๐‘ฅ0 = ๐‘
๐‘›
๐‘“(๐‘ฅ )
๐‘ฅ๐‘›+1 = ๐‘ฅ๐‘› + ๐‘“′ (๐‘ฅ๐‘› ) ;
๐‘›
๐‘ฅ0 = ๐‘Ž
7-savol
๐‘“(๐‘ฅ) = 0 tenglamaning (a;b) oraliqdagi ildizini vatarlar usulida izlanganda “a” nuqta qo’zg’almas bo’lishi
uchun qanday shart bajarilishi kerak?
A. ๐‘“ ′ (๐‘ฅ)๐‘“ ′′ (๐‘ฅ) < 0
B. ๐‘“ ′ (๐‘ฅ)๐‘“ ′′ (๐‘ฅ) > 0
C. ๐‘“(๐‘Ž)๐‘“(๐‘) < 0
D. ๐‘“ ′ (๐‘Ž)๐‘“ ′ (๐‘) < 0
8-savol
๐‘“(๐‘ฅ) = 0 tenglamaning (a;b) oraliqdagi ildizini vatarlar usulida izlanganda “b” nuqta qo’zg’almas bo’lishi
uchun qanday shart bajarilishi kerak?
A. ๐‘“ ′ (๐‘ฅ)๐‘“ ′′ (๐‘ฅ) > 0
B. ๐‘“(๐‘Ž)๐‘“(๐‘) < 0
C. ๐‘“ ′ (๐‘ฅ)๐‘“ ′′ (๐‘ฅ) < 0
D. ๐‘“ ′ (๐‘Ž)๐‘“ ′ (๐‘) < 0
9-savol
ex − 10x − 2 = 0 funksiyani [-1;0] oraliqdagi ildizini topishda ๐‘“′ (๐‘ฅ)๐‘“′′ (๐‘ฅ) < 0 shart bajarilsa vatarlar usuli bilan i=2
qadamlar orasidagi xatoligini aniqlang.
A. ๏‚ฝx2-x1๏‚ฝ=0.004 (shunga yaqinroq)
B. ๏‚ฝx2-x1๏‚ฝ=0.0014
C. ๏‚ฝx2-x1๏‚ฝ=0.00244
D. ๏‚ฝx2-x1๏‚ฝ=0.003444
Berilgan:
f(x) = ex − 10x − 2 ;
a = -1;
b=0
Yuqoridagi shartga ko’ra demak bizda x0 = b bo’lar ekan.
๐‘“(๐‘ฅ )(a−๐‘ฅ )
๐‘›
๐‘›
๐‘ฅ๐‘›+1 = ๐‘ฅ๐‘› − ๐‘“(a)−๐‘“(๐‘ฅ
shu formula bo’yicha ishlaymiz.
)
๐‘›
1-qadam:
๐‘ฅ1 = ๐‘ฅ0 −
๐‘“(๐‘ฅ0 )(a − ๐‘ฅ0 )
๐‘“(0) ∗ (−1 − 0)
๐‘“(0)
= 0 −
=
=
๐‘“(a) − ๐‘“(๐‘ฅ0 )
๐‘“(−1) − ๐‘“(0)
๐‘“(−1) − ๐‘“(0)
๐‘’ 0 − 10 ∗ 0 − 2
1-2
-1
= -1
=
=
≈ -0.10674774
(๐‘’ − 10 ∗ (−1) − 2) − (๐‘’ 0 − 10 ∗ 0 − 2)
(e-1 + 8) - (1-2)
e-1 + 9
2-qadam:
๐‘“(๐‘ฅ1 ) = e-0.10674774 − 10 ∗ (−0.10674774) − 2 ≈ -0.03377 ≈ 0
๐‘ฅ2 = ๐‘ฅ1 −
๐‘“(๐‘ฅ1 ) ∗ (−1 − (−0.10674774))
๐‘“(๐‘ฅ1 )(a − ๐‘ฅ1 )
= −0.10674774 −
≈. . ..
๐‘“(a) − ๐‘“(๐‘ฅ1 )
๐‘“(−1) − ๐‘“(๐‘ฅ1 )
Bunaqa savol tushmasa kerak. Keyin |๐‘ฅ1 − ๐‘ฅ2 | ni hisoblash kerak hali. Xullas ishlanishi shunaqa. Shuni
osonroq kalkulyatorsiz hisoblasa bo’ladigan variantdagisi tushishi mumkin.
Aniq integrallarni taqribiy hisoblashlar
(To’g’ri to’rtburchaklar, Trapetsiya, Simpson usullari)
Bularning xatoligi ham mos ravishda ๐‘‚(โ„Ž), ๐‘‚(โ„Ž2 ), ๐‘‚(โ„Ž4 ) bo’ladi.
To’g’ri to’rtburchaklar usulida xatoligi ๐‘‚(โ„Ž), formulasida h (belgisi TT)
Trapetsiya usulida xatoligi ๐‘‚ (โ„Ž2 ), formulasida
Simpson usulida xatoligi ๐‘‚ (โ„Ž4 ) formulasida
h
3
โ„Ž
2
(belgisi T)
(belgisi ะก)
10-savol
1
2
∫0 ๐‘’ −๐‘ฅ ๐‘‘๐‘ฅ aniq integralni to’g’ri to’rtburchaklar formulasi bo’yicha h=0.01 qadam bilan hisoblansa xatolik
tartibi qanday bo’ladi?
A. O(0,01)
B. O(0,0001)
C. O(0,0000001)
D. O(0,001)
To’g’ri to’rtburchaklar usulida xatoligi ๐‘‚(โ„Ž)
11-savol
๐‘
∫๐‘Ž ๐‘“(๐‘ฅ)๐‘‘๐‘ฅ aniq integralni trapetsiyalar formulasi bo’yicha h=0.01 qadam bilan hisoblansa xatolik tartibi
qanday bo’ladi?
A. O(0,0001)
B. O(0,000001)
C. O(0,001)
D. O(0,00001)
Trapetsiya usulida xatoligi ๐‘‚ (โ„Ž2 )
12-savol
1
∫0 ๐‘ ๐‘–๐‘›๐‘ฅ 2 ๐‘‘๐‘ฅ qiymatini Simpson formulasi bo’yicha O(10-4) aniqlikda hisoblash uchun h – qadamni qanday
olish kerak?
A. h=0,1
B. h=0,01
C. h=0,001
D. h=0,05
Simpson usulida xatoligi ๐‘‚ (โ„Ž4 )
13-savol
2
∫1 ๐‘๐‘œ๐‘ ๐‘ฅ 2 ๐‘‘๐‘ฅ qiymatini Simpson formulasi ko’ra h=0,1 qadam bilan hisoblasak xatolik qanday tartibda bo’ladi?
A. O(10-4)
B. O(10-3)
C. O(10-2)
D. O(10-1)
Simpson usulida xatoligi ๐‘‚ (โ„Ž4 )
14-savol
To’g’ri to’rtburchak formulasi to'g'ri keltirilgan javobni ko'rsating.
A. ๐ฝโ„Ž๐‘‡๐‘‡ (๐‘“) = โ„Ž ∑n-1
i=0 ๐‘“๐‘–+0.5
B.
h
C. ๐ฝโ„Ž๐‘‡ (๐‘“) = 2 {๐‘“0 + โ‹ฏ + ๐‘“๐‘›−1 + ๐‘“๐‘› }
h
h
D. ๐ฝโ„Ž๐ถ (๐‘“) = 3 ∑m-1
i=0 [๐‘“2๐‘– + 4๐‘“2๐‘–+1 + ๐‘“2๐‘–+2 ] = 3 [๐‘“0 + 4(๐‘“1 + . . . + ๐‘“2๐‘š−1 ) + 2(๐‘“2 +. . . +๐‘“2๐‘š−2 )]
To’g’ri to’rtburchaklar formulasida faqat h ishtirok etadi, belgisi TT
n-1
๐ฝโ„Ž๐‘‡๐‘‡ (๐‘“) = โ„Ž ∑ ๐‘“๐‘–+0.5
i=0
15-savol
Trapetsiya formulasi to'g'ri keltirilgan javobni ko'rsating.
โ„Ž
A. ๐ฝโ„Ž๐‘‡ (๐‘“) = {๐‘“0 + โ‹ฏ + ๐‘“๐‘›−1 + ๐‘“๐‘› }
2
B.
C. ๐ฝโ„Ž๐‘‡๐‘‡ (๐‘“) = โ„Ž ∑n-1
i=0 ๐‘“๐‘–+0.5
h
h
D. ๐ฝโ„Ž๐ถ (๐‘“) = 3 ∑m-1
i=0 [๐‘“2๐‘– + 4๐‘“2๐‘–+1 + ๐‘“2๐‘–+2 ] = 3 [๐‘“0 + 4(๐‘“1 + . . . + ๐‘“2๐‘š−1 ) + 2(๐‘“2 +. . . +๐‘“2๐‘š−2 )]
Trapetsiya formulasida h/2 ishtirok etadi, belgisi T
h
๐ฝโ„Ž๐‘‡ (๐‘“) = {๐‘“0 + โ‹ฏ + ๐‘“๐‘›−1 + ๐‘“๐‘› }
2
16-savol
Simpson formulasi to'g'ri keltirilgan javobni ko'rsating.
A.
B.
h
C. ๐ฝโ„Ž๐‘‡ (๐‘“) = 2 {๐‘“0 + โ‹ฏ + ๐‘“๐‘›−1 + ๐‘“๐‘› }
D. ๐ฝโ„Ž๐‘‡๐‘‡ (๐‘“) = โ„Ž ∑n-1
i=0 ๐‘“๐‘–+0.5
Simpson formulasida h/3 ishtirok etadi, belgisi ะก
m-1
๐ฝโ„Ž๐ถ (๐‘“) =
h
h
∑[๐‘“2๐‘– + 4๐‘“2๐‘–+1 + ๐‘“2๐‘–+2 ] = [๐‘“0 + 4(๐‘“1 + . . . + ๐‘“2๐‘š−1 ) + 2(๐‘“2 +. . . +๐‘“2๐‘š−2 )]
3
3
i=0
Eslab qoling yana bir bor!!!
To’g’ri to’rtburchaklar usulida xatoligi ๐‘‚(โ„Ž), formulasida h (belgisi TT)
Trapetsiya usulida xatoligi ๐‘‚ (โ„Ž2 ), formulasida
Simpson usulida xatoligi ๐‘‚ (โ„Ž4 ) formulasida
h
3
โ„Ž
2
(belgisi T)
(belgisi ะก)
Download