Algoritmlarni loyiyalash fani bo’yicha laboratoriya ishi-3 Bajarildi



Download 137,82 Kb.
Sana14.07.2022
Hajmi137,82 Kb.
#800681
Bog'liq
Algoritmlarni loyihalash 2


O`ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARNI RIVOJLANTIRISH VAZIRLIGI MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALAR UNIVERSITETI

ALGORITMLASH VA MATEMATIK MODELLASHTIRISH KAFEDRASI


ALGORITMLARNI LOYIYALASH FANI BO’YICHA
LABORATORIYA ISHI-3

Bajarildi:
2-kurs talabasi
CAL008-L1 - guruh
Begmatov J.

Tekshirildi:
Aliqulov Y.Q.


Toshkent – 2022
Jadval ko’rinishida berilgan funktsiyalar uchun eng kichik kvadratlar usuli. Empirik bog’lanish qonunlarining chiziqli va kvadratik modeli
1.Eng kichik kvadratlar usuli yordamida chiziqli modelni C++ dasturlash tilida aniqlang.
12-variant

Y

X

0.526

0.41

0.453

0.46

0.482

0.52

0.552

7.64893

0.436

7.36235

0.378

7.09613

Dastur kodi:
#include
using namespace std;
int main()
{
double a0, a1, x[10], y[10], sum1, sum2, sum3, sum4;
for (int i = 0; i <= 6; i++)
{
cout << "x[" << i << "]= "; cin >> x[i]; cout << endl;
sum1 += x[i];
sum3 += x[i] * x[i];
}
for (int i = 0; i <= 6; i++)
{
cout << "y[" << i << "]= "; cin >> y[i]; cout << endl;
sum2 += y[i];
sum4 += y[i] * x[i];
}
cout << "x summa = " << sum1 << endl;
cout << "x*x summa = " << sum2 << endl;
cout << "y summa = " << sum3 << endl;
cout << "x*y summa = " << sum4 << endl << endl;
a1 = (sum2 * sum3 - sum1 * sum4) / (8 * sum3 - sum1 * sum1);
a0 = (sum4 - sum1 * a1) / sum3;

cout << "y = " << a0 << "x + " << a1;}


Natija:___2.Eng_kichik_kvadratlar_usuli_yordamida_kvadratik_modelni_C++_dasturlash_tilida_aniqlang._Dastur_kodi'>Natija:


2.Eng kichik kvadratlar usuli yordamida kvadratik modelni C++ dasturlash tilida aniqlang.
Dastur kodi:
#include
using namespace std;
double determinantOfMatrix(double mat[3][3])
{
double ans;
ans = mat[0][0] * (mat[1][1] * mat[2][2] - mat[2][1] * mat[1][2])
- mat[0][1] * (mat[1][0] * mat[2][2] - mat[1][2] * mat[2][0])
+ mat[0][2] * (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]);
return ans;
}
void findSolution(double coeff[3][4])
{
double d[3][3] = {
{ coeff[0][0], coeff[0][1], coeff[0][2] },
{ coeff[1][0], coeff[1][1], coeff[1][2] },
{ coeff[2][0], coeff[2][1], coeff[2][2] },
};
double d1[3][3] = {
{ coeff[0][3], coeff[0][1], coeff[0][2] },
{ coeff[1][3], coeff[1][1], coeff[1][2] },
{ coeff[2][3], coeff[2][1], coeff[2][2] },
};
double d2[3][3] = {
{ coeff[0][0], coeff[0][3], coeff[0][2] },
{ coeff[1][0], coeff[1][3], coeff[1][2] },
{ coeff[2][0], coeff[2][3], coeff[2][2] },
};
double d3[3][3] = {
{ coeff[0][0], coeff[0][1], coeff[0][3] },
{ coeff[1][0], coeff[1][1], coeff[1][3] },
{ coeff[2][0], coeff[2][1], coeff[2][3] },
};
double D = determinantOfMatrix(d);
double D1 = determinantOfMatrix(d1);
double D2 = determinantOfMatrix(d2);
double D3 = determinantOfMatrix(d3);
if (D != 0) {
double x = D1 / D;
double y = D2 / D;
double z = D3 / D;
printf("Value of x is : %lf\n", x);
printf("Value of y is : %lf\n", y);
printf("Value of z is : %lf\n", z);
}
else {
if (D1 == 0 && D2 == 0 && D3 == 0)
printf("Infinite solutions\n");
else if (D1 != 0 || D2 != 0 || D3 != 0)
printf("No solutions\n");
}
}
int main()
{
double a[10], b[10], sum1, sum2, sum3, sum4, sum5, sum6, sum7;
for(int i=0; i<6; i++)
{
cout<<"x["<>a[i]; cout<sum1+=a[i];
sum3+=a[i]*a[i];
sum4+=a[i]*a[i]*a[i];
sum7+=a[i]*a[i]*a[i]*a[i];
}
for(int i=0; i<6; i++)
{
cout<<"y["<>b[i]; cout<sum2+=b[i];
sum5+=a[i]*b[i];
sum6+=a[i]*a[i]*b[i];
}
cout<<"x summa = "<cout<<"x*x summa = "<cout<<"x kub summa = "<cout<<"x 4-daraja summa = "<cout<<"y summa = "<cout<<"y*x summa = "<cout<<"x*x*y summa = "<double coeff[3][4] = {
{ sum7, sum4, sum3, sum6 },
{ sum4, sum3, sum1, sum5 },
{ sum3, sum1, 6, sum2 },
};
findSolution(coeff);
return 0;
}
Natija:

3.Topilgan modellarni tahlil qiling.
Dastur kodi:
#include
using namespace std;
int main ()
{
double x[10], f[10], y[10], y1[10], res;
for(int i=0; i<6; i++)
{
cout<<"x["<>x[i]; cout<}
for(int i=0; i<6; i++)
{
cout<<"f["<>f[i]; cout<}
for(int i=0; i<6; i++)
{
y[i]=10.6386*x[i]+0.0196839;
cout<<"y["<}
cout<<"CHIZIQLI MODEL TAHLILI :"<for(int i=0; i<6; i++)
{
res=fabs(f[i]-y[i]);
cout<}
cout<cout<<"KVADRATIK MODEL TAHLILI :"<for(int i=0; i<6; i++)
{
y1[i]=-142.142857*x[i]*x[i]+35.412143*x[i]-0.811307;
cout<<"y["<}
for(int i=0; i<6; i++)
{
res=fabs(f[i]-y1[i]);
cout<}


Natija:


Download 137,82 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
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