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
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; }
Dostları ilə paylaş: