Amaliy ishi Guruh: 241-21
Bajardi: Sultonboyev Umid
Tekshirdi: Nasriddinov Saloxiddin
Toshkent 2023
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));
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.