Guruh Abdurashidov Bexruz
Download 133.09 Kb.
|
Algaritim loyihalash1 2-variant
- Bu sahifa navigatsiya:
- Dastur kodi
- Tenglama yechimi: 0.500183 x3 -0.2x2+0.5x-1.4=0
2-amaliy ishi.
Mavzu: Algebraik va transtendent tenglamalarni yechishda oraliqni teng ikkiga bo’lish, iterasiya usullari. Tenglamalarni yechishda vatarlar va Nyuton usullari. Yaqinlashish tezligi Berilgan topshiriq: 1. Aniqlangan oraliqda ildizning taqribiy qiymatini 0.001 aniqlikda hisoblang. 2. Kesmani teng ikkiga bo‘lish usuli bilan taqribiy hisoblang. 1. Dastur kodi: let kesmaniTengIkkigaBoLish = (a, b, epsilon) => { let x1, x2, y1, y2; x1 = a; y1 = tan(0.58x+0.1) – Math.pow(x,2); let k = 0; while (true) { k++; x2 = a + (b - a) / Math.pow(2, k); y2 = tan(0.58x+0.1) – Math.pow(x,2); if (Math.abs(y2 - y1) < epsilon) { break; } x1 = x2; y1 = y2; } return (x1 + x2) / 2; } let a = 0.5; let b = 1.0; let epsilon = 0.001; let x = kesmaniTengIkkigaBoLish(a, b, epsilon); console.log("Tenglama yechimi: x =", x); Algoritmi: 1.1. x1, y1 o'zgaruvchilarni a qiymati bilan aniqlang va x1 qiymatini x1, y1 blokida saqlang. 1.2. k=0 deb olamiz. 1.3. "while" tsiklida toki x2 = a + (b - a) / 2^k ni hisoblash. 1.4. y2 qiymatini tan(0.58 * x2 + 0.1) - x2^2 hisobidan toping. 1.5. y2-y1 ni epsilon dan kichikligini tekshiring. 1.6. Agar epsilon dan kichik bo'lsa tsiklni to'xtating. 1.7. x1 = x2, y1 = y2. 1.8. x1 va x2 o'zgaruvchilar yordamida tenglamani yeching. 1.9. Yakunida x qiymatini qaytarish. Tenglama yechimi: 0.500183 x3 -0.2x2+0.5x-1.4=0 Bajaralishi tartibi: 1.Dastur kodi: function f(x) { return Math.pow(x, 3) - 0.2 * Math.pow(x, 2) + 0.5 * x - 1.4; } let a = 0, b = 1.5, eps = 0.001; let c, fc; while (b - a > eps) { c = (a + b) / 2; fc = f(c); if (fc == 0) { break; } else if (f(a) * fc < 0) { b = c; } else { a = c; } } cout << "Tenglamaning yechimi: " << c << endl; return 0; } Natija: Start | v Define f(x) | v Initialize a, b, eps | v While (b - a > eps) | |----- Calculate c = (a + b) / 2 | |----- Calculate fc = f(c) | |----- If (fc == 0) | | | v |----- break | |----- Else if (f(a) * fc < 0) | | | v |----- b = c | |----- Else | v ----- a = c | v Output c as the root of f(x) | v End Download 133.09 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2025
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling