Texnologiyalari va

O’zbekiston Respublikasi Axborot
Texnologiyalari va
Komunikatsiyalarini rivojlantirish vazirligi
Muhammad
al-Xorazimiy nomidagi
Toshkent Axborot Texnologiyalar Universiteti
Fan:
Algoritmlarni loyihalash
3- topshiriq
Guruh:CAL006-1
Bajardi : Kabirov O’rolbek
Tekshirdi :
Kamalova Sevara
Toshkent 2024
Berilgan jadvaldan n nomerdan boshlab 22 tа qiymat ko‘chirib olinsin. bunda
n talabalarni guruh jurnalidagi tartib raqami. Jadvaldagi variantga deb olinadi va
variant jadvali i=0,1,2,…,n ko‘rinishida belgilanadi.
Variant 10
Xi^2
fi*Xi
Xi^4
Xi^3
fi*Xi^2
0
0
0
0
0
0,01
0,47231
0,0001
0,001 0,047231
0,04 0,989176
0,0016
0,008 0,197835
0,09
1,5504
0,0081
0,027
0,46512
0,16
2,156
0,0256
0,064
0,8624
0,25
2,805
0,0625
0,125
1,4025
0,36
3,498
0,1296
0,216
2,0988
0,49
4,2336
0,2401
0,343
2,96352
0,64
5,0128
0,4096
0,512
4,01024
0,81
5,8347
0,6561
0,729
5,25123
1
6,7
1
1
6,7
1,21
7,6087
1,4641
1,331
8,36957
1,44
8,56092
2,0736
1,728
10,2731
1,69
9,55747
2,8561
2,197 12,42471
1,96
10,5987
3,8416
2,744 14,83818
2,25
11,685
5,0625
3,375
17,5275
2,56 12,81678
6,5536
4,096 20,50685
2,89 13,99423
8,3521
4,913 23,79019
3,24 15,21738 10,4976
5,832 27,39128
3,61 16,48613 13,0321
6,859 31,32365
4
17,8
16
8
35,6
28,7 157,5773 72,2666
44,1 226,0439
y=2,1917x+4,5083
Xi
fi
y=-0,00005x^2+219*x+4,5083
4,5083
0
4,5
4,5083
4,72747
0,1
4,7231
4,7272995
4,94664
0,2
4,94588
4,946298
5,16581
0,3
5,168
5,1652955
5,38498
0,4
5,39
5,384292
5,60415
0,5
5,61
5,6032875
5,82332
0,6
5,83
5,822282
6,04249
0,7
6,048
6,0412755
6,26166
0,8
6,266
6,260268
6,48083
0,9
6,483
6,4792595
6,7
1
6,7
6,69825
6,91917
1,1
6,917
6,9172395
7,13834
1,2
7,1341
7,136228
7,35751
1,3
7,3519
7,3552155
7,57668
1,4
7,5705
7,574202
7,79585
1,5
7,79
7,7931875
8,01502
1,6 8,010489
8,012172
8,23419
1,7
8,2319
8,2311555
8,45336
1,8
8,4541
8,450138
8,67253
1,9
8,67691
8,6691195
8,8917
2
8,9
8,8881
21 140,7009
Dastur kodi: CPP da
#include
#include
using namespace std;
int main(){
int n;
cout<<"Qiymatlar sonini kiriting (n): "; cin>>n;
float x[n+1],f[n+1],s1=0,s2=0,s3=0,s4=0,s5=0,s6=0,s7=0,d,d0,d1,d2;
cout<<"X larning qiymatini kiriting:\n";
for(int i=0; i<=n; i++){
Series1
0
2
4
6
8
10
1 2 3 4 5 6
7 8 9 10 11
12 13 14 15 16
17 18 19 20 21
Chart Title
Series1
Series2
Series3
cout<<"x["<>x[i];
}
cout<<"Y larning qiymatini kiriting:\n";
for(int i=0; i<=n; i++){
cout<<"y["<>f[i];
}
for(int i=0; i<=n; i++){
s1=s1+x[i];
s2=s2+f[i];
s3=s3+pow(x[i],2);
s4=s4+x[i]*f[i];
s5=s5+pow(x[i],3);
s6=s6+pow(x[i],4);
s7=s7+pow(x[i],2)*f[i];
}
cout<<"\n Chiziqli funksiya koefsentlari:\n";
cout<<"a[0]= "<<(s4*(n+1)-s1*s2)/(s3*(n+1)-s1*s1)<<" va a[1]= "<<(s2*s3-s4*s1)/(s3*(n+1)-
s1*s1)<cout<<" Kvadrat funksiya koefsentlar: \n";
d=(s6*s3*(n+1)+s5*s1*s3+s3*s5*s1-(s3*s3*s3+s5*s5*(n+1)+s1*s1*s6));
d0=(s7*s3*(n+1)+s5*s1*s2+s4*s1*s3-(s3*s3*s2+s4*s5*(n+1)+s1*s1*s7));
d1=(s6*s4*(n+1)+s7*s1*s3+s5*s2*s3-(s3*s4*s3+s1*s2*s6+(n+1)*s7*s5));
d2=(s6*s3*s2+s5*s4*s3+s5*s1*s7-(s3*s3*s7+s1*s4*s6+s5*s5*s2));
cout<<"a[0]= "<cout<<"\n Anniq wunaqa buladi!! ";
cout<return 0;
}
2-
misol: N talabaning tartib raqami. n1=N%2, ya’ni 2ga bo’lgandagi qoldig’i. , Funksiyani furye qatoriga
yoying.
Masalan: N=5 bo’lsa, f(x)=7x2-22, 1 1 ( ) ( 2)
( 1) (5 3) n N f x N x N + = + +- [ ] ; pp [ ] ;
N=10 variant
f(x)=17x+47; buladi;
import math
# Funksiyani aniqlash
def f(x):
return 12*x+47
# X o'qini yaratish
x_values = [i * 0.01 for i in range(int(2*math.pi/0.01))]
# Furiye qatorini hisoblash
def fourier_series(x_values, n):
a0 = sum(f(x) for x in x_values) / len(x_values)
an = lambda n: (2 / len(x_values)) * sum(f(x) * math.cos(2 * math.pi * n * x) for x in x_values)
bn = lambda n: (2 / len(x_values)) * sum(f(x) * math.sin(2 * math.pi * n * x) for x in x_values)
return lambda x: a0/2 + sum(an(i) * math.cos(2 * math.pi * i * x) + bn(i) * math.sin(2 * math.pi * i * x) for i
in range(1, n+1))
# Natijani ko'rsatish
fourier_approximation = fourier_series(x_values, 50)
print(fourier_approximation(15))
3-misol
1.
Variantda berilgan graf qirralari narxlari matritsasiga ko‘ra planar graf chizing. Izoh: C=(Cij)
matritsa Cij elementi grafning i-va j-uchlarini tutashtiruvchi qirra bo‘yicha harakat narxi. Cij=0
bo‘lgan hol i-, j- uchlarini tutashtiruvchi qirra yo‘qligini bildiradi.
10-variant
E’TIBORINGIZ UCHUN RAHMAT
Document Outline - O’zbekiston Respublikasi Axborot Texnologiyalari va
- Muhammad al-Xorazimiy nomidagi Toshkent Axborot Texnologiyalar Universiteti
- Variant 10
- Dastur kodi: CPP da
- 2- misol: N talabaning tartib raqami. n1=N%2, ya’ni 2ga bo’lgandagi qoldig’i. , Funksiyani furye qatoriga yoying.
- 1. Variantda berilgan graf qirralari narxlari matritsasiga ko‘ra planar graf chizing. Izoh: C=(Cij) matritsa Cij elementi grafning i-va j-uchlarini tutashtiruvchi qirra bo‘yicha harakat narxi. Cij=0 bo‘lgan hol i-, j- uchlarini tutashtiruvchi qirra yo...
|