Muhammad al-Xorazmiy nomidagi
Toshkent Axborot Texnologiyalari Universiteti
Algoritmlarni loyihalash fanidan
MUSTAQIL ISHI
Bajardi: Alisherov Izzatullo
Tekshirdi: Mirzayev Anvar
Toshkent-2024
Variant parametrlarini quyidagicha aniqlang: n1={N%3}+1; n2={N%5}+1; n3={N/7}+1, bu yerda N talabalarning potokdagi nomeri. {N%3} bu N sonini 3 ga bo’lgandagi qoldig’i. Misol: N=7 {7%3}=1.
Tenglamani hosil qiling:
Tenglamaning yechim oralig’ini toping. Vatarlar usuli yordamida ildizlarni e=10-5 aniqlik bilan hisoblash algoritmini tuzing. Bunday aniqllika erishish uchun zarur qadamlar sonini aniqlang.
# Oraliqni ikkiga bo’lish usuli
N = 10
n1 = (N % 3) + 1
n2 = (N % 5) + 1
n3 = (N % 7) + 1
a = 1
b = 2
e = 0.00001
def result(x):
return x**3+n1*(x**2)-n2*x-n3
z = 0
if result(a)*result(b) < 0:
while abs(b-a) > e:
if result(a) * result((a+b)/2) < 0:
b = (a+b)/2
else:
a = (a+b)/2
z += 1
x = (a+b)/2
print(f"x={x}")
print(f"f(a)={result(x)}")
print(f"qadamlar soni = {z}")
2. Ushbu masalani Nyuton usuli orqali yechis algoritmini yozing. Ikkala usulda ham yechimlarni oling. Ko’ring chiqilgan usullar samaradorligini taqqoslang.
N = 10
n1 = (N % 3) + 1
n2 = (N % 5) + 1
n3 = (N % 7) + 1
a = 1
b = 2
e = 0.00001
def f(x):
return x**3+n1*(x**2)-n2*x-n3
def f1(x):
return 3*(x**2)+2*n1*x-n2
def f2(x):
return 6*x+2*n1
if f2(a)*f(a) > 0:
b = a
else:
b = b
x1 = b-f(b)/f1(b)
z = 0
if f(a)*f(b) < 0:
while abs(x1-b) > e:
b = x1
x1 = b-f(b)/f1(b)
z += 1
print(f"x={x1}")
print(f"f(a)={f(x1)}")
print(f"qadamlar soni = {z}")
Nyuton usuli va Oraliqni ikkiga bo’lish usuli orqali 2 xil algoritmda dastur tuzib test qilib ko’rdim va xulosa qilish mumkinki Nyuton usuli natijani olish uchun anchagina samarali usul ekan
3. Chiziqli dasturlash masalasini hosil qiling:
Geometrik usulda mavjud bo’lgan yechimlar sohasini toping. Tayanach yechimlarni aniqlang. Optimal yechimni toping.
Egizak masalani shakllantiring va u uchun CHDM tuzib, t ayanch yechimlarni aniqlang. Shuningdek geometrik usulda optimal yechimni toping.
Egizak Masala
CHDM ni simpleks usulida hisoblang. Topilgan yechimlardan iqtisodiy tahlil o’tkazing. Tegishli matematik modelni ishlab chiqarishni takomillashtirish bo’yicha tavsiyalarni shakllantiring.
|