O‘zbekiston respublikasi axborot texnologiyalari va kommunikatsiyalarini rivojlantirish vazirligi muhammad al-xorazmiy nomidagi



Yüklə 338,34 Kb.
tarix09.05.2023
ölçüsü338,34 Kb.
#109971
Algoritm 12


O‘ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA
KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
Kompyuter injiniring fakulteti



Algoritmlarni loyihalash fanidan


Amaliy ishi
Guruh: 241-21
Bajardi: Sultonboyev Umid
Tekshirdi: Nasriddinov Saloxiddin

Toshkent 2023





  1. Matritsalar ustida amallarni bajaring.

#include


#include
#include
using namespace std;
vector calculateExpression(vector& A, vector& B) {
vector result;
int n = A.size();
for (int i = 0; i < n; i++) {
int a = A[i];
int b = B[i];
int temp = a*(a*a-b)-2*(b+a)*b;
result.push_back(temp);
}
return result;
}
int main() {
vector A = {2,3,1,-1,2,4,5,3,0};
vector B = {2,7,13,-1,0,5,5,13,21};
vector result = calculateExpression(A, B);
cout << "Natija: ";
for (int i = 0; i < result.size(); i++) {
cout << result[i] << " ";
}
cout << endl;
return 0;
}

2-Topshiriq . n = 10 uchun chap va o'ng to'rtburchaklar formulalari yordamida integralni hisoblang, olingan natijalarni taqqoslash orqali aniqlikni baholash.

#include

#include
using namespace std;

double f(double x) {

return sqrt(1.1*x*x+0.9)/1.6+sqrt(0.8*x*x+1.4);
}

int main() {


int n = 10;
double a = 0.6;
double b = 2.4;
double h = (b - a) / n;

double sumLeft = 0.0;


for (int i = 0; i < n; i++) {
double xi = a + i * h;
sumLeft += f(xi) * h;
}

double sumRight = 0.0;


for (int i = 1; i <= n; i++) {
double xi = a + i * h;
sumRight += f(xi) * h;
}

cout << "Chap tortburchak : " << sumLeft << endl;


cout << "O'ng tortburchak: " << sumRight << endl;

return 0;


3-Topshiriq Trapetsiya formulasi yordamida integralni hisoblang(E=0.001). 2. n=8 uchun Simpson formulasi yordamida integralni hisoblang; jadvalini tuzish orqali natijaning xatosini baholang.


#include
#include
using namespace std;

double f(double x) {


return 1/sqrt(x*x+2);
}

int main() {


double a = 0.5;
double b = 1.3;
double E = 0.001;
double I = 0.0;
double I_old = 0.0;
int n = 1;
double h = (b-a)/n;

do {
I_old = I;


I = (f(a) + f(b))/2.0;
for (int i = 1; i < n; i++) {
double x = a + i*h;
I += f(x);
}
I *= h;
n *= 2;
h = (b-a)/n;
} while (abs(I - I_old) >= E);

cout << "Integralning yaqinlashishi: " << I << endl;


cout << "Subintervallar soni: " << n << endl;

return 0;


}

#include


#include
using namespace std;

double f(double x) {


return sqrt(x+1)*cos(x*x);
}

int main() {


double a = 0.2;
double b = 1.8;
int n = 8;
double h = (b-a)/n;
double sum_odd = 0.0;
double sum_even = 0.0;

for (int i = 1; i < n; i += 2) {


double x = a + i*h;
sum_odd += f(x);
}
for (int i = 2; i < n; i += 2) {
double x = a + i*h;
sum_even += f(x);
}

double I = (h/3.0)*(f(a) + 4.0*sum_odd + 2.0*sum_even + f(b));

double error = abs(I - 0.462985);
cout << "Integralning yaqinlashishi: " << I << endl;
cout << "Absolute xatoligi: " << error << endl;

return 0;


} 4-Topshiriq kesmani ikkiga bo`lish usuli

#include
#include
using namespace std;

double f(double x) {


return exp(-x*x);
}

double enumerate(double x0, double x1, double eps) {


double x = x0;
while (x <= x1) {
if (abs(f(x)) <= eps) {
return x;
}
x += eps;
}
return NAN;
}

double chords(double x0, double x1, double eps) {


double x = x1;
double x_prev = x0;
while (abs(x - x_prev) > eps) {
x_prev = x;
x -= f(x)/((f(x) - f(x0))/(x - x0));
}
return x;
}

int main() {


double x0 = 0.0;
double x1 = 2.0;
double eps = 0.0001;

double root_enum = enumerate(0, 2, eps);


if (!isnan(root_enum)) {
cout << "Koren naydenniy pereborom: " << root_enum << endl;
} else {
cout << "Koren ne nayden pereborom" << endl;
}

double root_chords = chords(x0, x1, eps);


cout << "Konen naydenniy xord- kasatelnix: " << root_chords << endl;

return 0;


}


5-Topshiriq Ch.P.M. grafik va simpleks usulida yeching








Xulosa qilib aytganda, chiziqli dasturlash - bu talablar chiziqli munosabatlar bilan ifodalangan matematik modellarni echishning kuchli usuli. Bu matematik dasturlashning alohida holati bo'lib, chiziqli tenglik va chiziqli tengsizlik cheklovlariga bog'liq bo'lgan chiziqli maqsad funksiyasini optimallashtirishni o'z ichiga oladi. Chiziqli dasturlash algoritmlari chiziqli tengsizliklar tizimi bilan aniqlangan qavariq politopning mumkin bo'lgan hududida optimal nuqtani topadi. Chiziqli dasturlash masalalari resurslarni taqsimlash muammolari, foyda-xarajatlarni almashtirish muammolari va qat'iy talablar muammolarini hal qilish uchun ishlatilishi mumkin. Chiziqli dasturlash masalalarini echish uchun ishlatilishi mumkin bo'lgan har xil turdagi hal qiluvchilar mavjud va hal qiluvchi tanlash hal qilinayotgan aniq masalaga bog'liq. Umuman olganda, chiziqli dasturlash qaror qabul qilish va optimallashtirish uchun qimmatli vosita bo'lib, u biznes, muhandislik va boshqa sohalarda ko'plab amaliy dasturlarga ega.

Yüklə 338,34 Kb.

Dostları ilə paylaş:




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin