Muhammad al-xorazmiy nomidagi toshkent axborot texnologiyalari universiteti radio va mobil aloqa fakulteti fan: Algoritmlarni loyihalash Fakultet: Mobil tizimlar Guruh: cal002-L1 Bajardi: Umirov Ulugbek



Download 425,55 Kb.
Sana30.05.2022
Hajmi425,55 Kb.
#620372
Bog'liq
algoritmlash




MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI

RADIO VA MOBIL ALOQA FAKULTETI
Fan: Algoritmlarni loyihalash
Fakultet: Mobil tizimlar
Guruh: CAL002-L1
Bajardi: Umirov Ulugbek

28-variant
1.Berilgan integral qiymatini to‘g‘ri to‘rtburchaklar, trapetsiyalar, Simpson usullarida ε>0 aniqlikda hisoblang. Aniqlikka erishganlik sharti sifatida |S2n-Sn|;

Trapetsiyalar usuli
public class Misol2TrapetsiyalarUsuli {
public static void main(String[] args) {
float x0 = 0;
float xn = 2;
int n = 10;
System.out.println("Natija: " + Math.round(trapezoidal(x0, xn, n) * 10000.0) / 10000.0);
}
static float y(float x) {
return (float) ((float) (x*x + x + 1)/(Math.sqrt(x*x*x + 5)));
}
static float trapezoidal(float a, float b, float n) {
float h = (b - a) / n;
float s = y(a) + y(b);
for (int i = 1; i < n; i++)
s += 2 * y(a + i * h);
return (h / 2) * s;
}
}

Simpson usuli
public class Misol2SimpsonUsuli {
public static void main(String[] args) {
float lower_limit = 0; // quyi chegara
float upper_limit = 2; // yuqori chegara
int n = 10;
System.out.println("Javob: " + simpsons_(lower_limit, upper_limit, n));
}
static float func(float x) {
return (float) ((float) (x*x + x + 1)/(Math.sqrt(x*x*x + 5)));
}
static float simpsons_(float ll, float ul,
int n) {
float h = (ul - ll) / n;
float[] x = new float[100];
float[] fx = new float[100];
for (int i = 0; i <= n; i++) {
x[i] = ll + (i * h);
fx[i] = func(x[i]);
}
float res = 0;
for (int i = 0; i <= n; i++) {
if (i == 0 || i == n)
res += fx[i];
else if (i % 2 != 0)
res += 4 * fx[i];
else
res += 2 * fx[i];
}
res = res * (h / 3);
return res;
} }


To'rtburchaklar usuli
public class Misol2TortburchakUsuli {
public static void main(String[] args) {
double a, b, w, sum, x_i;
int i, n;

a = 0.0;
b = 2.0;


n = 10;

w = (b - a) / n;


sum = 0.0;
double e = Math.E;
for (i = 1; i <= n; i++) {
x_i = a + (i - 1) * w;
sum += (w * (((x_i*x_i + x_i + 1)/(Math.sqrt(x_i*x_i*x_i) + 5))));
}
System.out.println("Natija: " + sum);
}
}

1.2 Berilgan tenglamaning taqribiy yechimini ε>0 aniqlikda urinmalar (Nyuton) va vatarlar usullarida hisoblang. Aniqlikka erishganlik sharti sifatida |xn+1-xn|< ε;

package Laboratoriya1.Misol1;


import java.util.Scanner;
Urinmalar usuli
public class Misol1UrinmalarUsuli {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = 0;
System.out.print("[a, b] oraliqni kiritng: ");
double a = scanner.nextDouble(), b = scanner.nextDouble();
double x1, x2 = 0, e = 0.001;
if (func1(a) < 0 && func1(b) > 0) {
if (func2((float) a) * func3((float) a) > 0) {
do {
x1 = b;
x1 = x2;
x2 = x1 - func1(x1) / func2((float) x1);
} while (Math.abs(x2 - x1) > e);
}
if (func2((float) a) * func3((float) a) < 0) {
do {
x1 = a;
x1 = x2;
x2 = x1 - func1(x1) / func2((float) x1);
}
while (Math.abs(x2 - x1) > e);
}
System.out.println(x2);
} else
System.out.println("Bu oraliqda yechim yo'q.");
}
public static float func1(double x)
{
return (float) (5*x-8*Math.log(x) - 8);
}
public static float func2(float x)
{
return (float) (5-8/x);
}
public static float func3(float x)
{
return 8/x*x;
}

}

Vatarlar usuli


public class Misol1VatarlarUsuli {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = 0;
System.out.print("[a, b] oraliqni kiritng: ");
double a = scanner.nextDouble(), b = scanner.nextDouble();
double x1, x2 = 0, e = 0.001;
if (func1(a) < 0 && func1(b) > 0) {
if (func2((float) a) * func3((float) a) < 0) {
do {
x1 = b;
x1 = x2;
x2 = x1 - func1(x1) * (x1 - a) / (func1(x1) - func1(a));
} while (Math.abs(x2 - x1) > e);
}
System.out.println(x2);
} else {
System.out.println("Bu oraliqda yechim yo'q.");
}
}
public static float func1(double x) {
return (float) (5*x-8*Math.log(x) - 8);
}
public static float func2(float x) {
return (float) (5-8/x);
}
public static float func3(float x) {
return (float) 8/(x*x);
}
}
Download 425,55 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2025
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish