108-guruh talabasi Rustamov Ilhomning «Algoritmlarni loyihalash»fanidan 8-hafta Mustaqil ish topshirig'i


) Laboratoriya mashg’ulotlari uchun masalalar. Quyidagi masalalar uchun dastur tuzing



Yüklə 1,64 Mb.
səhifə2/2
tarix01.01.2022
ölçüsü1,64 Mb.
#107050
1   2
algo 8

2) Laboratoriya mashg’ulotlari uchun masalalar. Quyidagi masalalar uchun dastur tuzing.

1) Lagranj ko’phadi. Quyidagi jadval qiymatlaridan foydalanib ko’phad toppish dasturini tuzing va y(20), y(-5) qiymatlarini toping

I

0

1

2

X

2

-8

4

y

2

-5

3

Topilgan y=f(x) funksiya uchun Furye qatorini tuzing. A0, an, bn koeffitsentlarni taqribiy integrallash formulalari bilan dastur yordamida toping

f(x)=

Dastur kodi

#include

#include

#include

using namespace std;

int main(){

float n,xx;

float x[100], y[100];

cout<<"nuqtalar sonini kiriting ";

cin>>n;


cout< for(int i=0; i<=n; i++)

{

cin>>x[i]>>y[i];



}

cout<<"x agrument qiymatini kiriting ";

cin>>xx;

double S=0;

for(int i=0; i<=n;i++)

{

double p=1;



for(int j=0; j<=n; j++)

if(i!=j)

p*=(xx-x[j])/(x[i]-x[j]);

p*=y[i];

S+=p;

}

cout<

cout<

main(); }





a0 koeffitsentni taqribiy integrallash formulalari bilan dastur kodi

#include

#include

using namespace std;

double funk(double x)

{

return ((-x*x+36*x+52)/60);



}

int main()

{

double a,b,S=0, xa;



int n=100;

cout<<"integral chegarasini kiriting"<

cin>>a>>b;

xa=a+fabs(b-a)/n;

while (xa

{

S+=funk(xa);



xa+=fabs(b-a)/n;

}

S+=(funk(a)/2+funk(b))/2;



S=S*fabs(b-a)/n;

cout << S/M_PI;

return 0; }



2-usul a0 koeffitsentni taqribiy integrallash formulalari bilan dastur kodi

#include

#include

using namespace std;

double x[10],y[10],z;

int i,j;


double funk( int n,double z) {

double k,p;

k=0;

for(j=0;j<=n;j++){



p=1;

for(i=0;i<=n;i++){

if(i!=j)

p*=(z-x[i])/(x[j]-x[i]);}

k+=y[j]*p;}

return k ;

}

int main(){



int n;

cout<<"Fure qator koeffitsiyentining qiymatini aniqlash";

cout<<"\nN= "; cin>>n;

for(i=0;i<=n;i++) {

cout<<"x["<>x[i];

cout<<"y["<>y[i];

}

// a0 koeffitsentni hisoblash



double a,b , a0=0, xa;

int n1=100;

cout<<"integral chegarasini kiriting"<

cin>>a>>b;

cout<

xa=a+fabs(b-a)/n1;

while(xa

{

a0+=funk(n,xa);



xa+=fabs(b-a)/n1;

}

a0+=(funk(n,a)+funk(n,b))/2;



a0=a0*fabs(b-a)/n1;

cout<<"a0 "<

return 0;

}



an koeffitsentni taqribiy integrallash formulalari bilan dastur kodi

#include

#include

using namespace std;

double funk(double x)

{

return ((-x*x+36*x+52)/60)*cos(x);



}

int main()

{

double a,b,S=0, xa;



int n=100;

cout<<"integral chegarasini kiriting"<

cin>>a>>b;

xa=a+fabs(b-a)/n;

while (xa

{

S+=funk(xa); xa+=fabs(b-a)/n;



}

S+=(funk(a)/2+funk(b))/2;

S=S*fabs(b-a)/n;

cout << S/M_PI;

return 0; }



bn koeffitsentni taqribiy integrallash formulalari bilan dastur kodi

#include

#include

using namespace std;

double funk(double x)

{

return ((-x*x+36*x+52)/60)*sin(x);



}

int main()

{

double a,b,S=0, xa;



int n=100;

cout<<"integral chegarasini kiriting"<

cin>>a>>b;

xa=a+fabs(b-a)/n;

while (xa

{

S+=funk(xa);



xa+=fabs(b-a)/n;

}

S+=(funk(a)/2+funk(b))/2;



S=S*fabs(b-a)/n;

cout << S/M_PI;

return 0; }


2) Berilgan jadval funksiya uchun ko’phad tuzing



I

0

1

2

X

0

1

2

Y

6

2

0

Topilgan y=f(x) funksiya uchun Furye qatorini tuzing. A0, an, bn koeffitsentlarni taqribiy integrallash formulalari bilan dastur yordamida toping

F(x) = x*x-5x+6

#include

#include

#include

using namespace std;

int main(){

float n,xx;

float x[100], y[100];

cout<<"nuqtalar sonini kiriting ";

cin>>n;

cout<

for(int i=0; i<=n; i++)

{

cin>>x[i]>>y[i];



}

cout<<"x agrument qiymatini kiriting ";

cin>>xx;

double S=0;

for(int i=0; i<=n;i++)

{

double p=1;



for(int j=0; j<=n; j++)

if(i!=j)

p*=(xx-x[j])/(x[i]-x[j]);

p*=y[i];

S+=p;

}

cout<

cout<

main(); }





a0 koeffitsentni taqribiy integrallash formulalari bilan dastur kodi

#include

#include

using namespace std;

double funk(double x)

{

return (x*x-5*x+6);



}

int main()

{

double a,b,S=0, xa;



int n=100;

cout<<"integral chegarasini kiriting"<

cin>>a>>b;

xa=a+fabs(b-a)/n;

while (xa

{

S+=funk(xa);



xa+=fabs(b-a)/n;

}

S+=(funk(a)/2+funk(b))/2;



S=S*fabs(b-a)/n;

cout << S/M_PI;

return 0; }



an koeffitsentni taqribiy integrallash formulalari bilan dastur kodi

#include

#include

using namespace std;

double funk(double x)

{

return (x*x-5*x+6)*cos(x);



}

int main()

{

double a,b,S=0, xa;



int n=100;

cout<<"integral chegarasini kiriting"<

cin>>a>>b;

xa=a+fabs(b-a)/n;

while (xa

{

S+=funk(xa);



xa+=fabs(b-a)/n;

}

S+=(funk(a)/2+funk(b))/2;



S=S*fabs(b-a)/n;

cout << S/M_PI;

return 0; }



bn koeffitsentni taqribiy integrallash formulalari bilan dastur kodi

#include

#include

using namespace std;

double funk(double x)

{

return (x*x-5*x+6)*sin(x);



}

int main()

{

double a,b,S=0, xa;



int n=100;

cout<<"integral chegarasini kiriting"<

cin>>a>>b;

xa=a+fabs(b-a)/n;

while (xa

{

S+=funk(xa);



xa+=fabs(b-a)/n;

}

S+=(funk(a)/2+funk(b))/2;



S=S*fabs(b-a)/n;

cout << S/M_PI;



return 0; }


Yüklə 1,64 Mb.

Dostları ilə paylaş:
1   2




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

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin