Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream.h>
- #include <iomanip.h>
- #include <math.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- int i,j,k, m;
- double P, Y[101], G[101][101], B[101], xT[101], yT[101], D[101];
- void main(void)
- {
- //Sostavlenie matricsi G
- //---------------------------------------|
- const a=4;
- const b=7;
- const m=4;
- const n=4;
- double x[101];
- for (i=0; i<m; i++)
- {
- x[i]=a+i*(b-a)/(m-1);
- }
- for (i=0; i<m; i++)
- {
- for (j=0; j<m; j++)
- {
- G[i][j]=pow(x[i],j);
- }
- }
- for (i=a; i<=b; i++)
- {
- B[i-4]=exp(i)/pow(i,3)-pow(sin(i),3);
- }
- //---MG----------------------------------|
- int size=m;
- double koeff, koeff2, C[101];
- for (i=0; i<size; i++)
- {
- for (j=i; j<size-1; j++)
- {
- koeff=G[j+1][i]/G[i][i];
- B[j+1]-=B[i]*koeff;
- for (k=i; k<size; k++)
- {
- G[j+1][k]-=G[i][k]*koeff;
- }
- }
- }
- for (i=size-1; i>=0; i--)
- {
- for (j=i-1; j>=0; j--)
- {
- koeff2=G[j][i]/G[i][i];
- B[j]-=B[i]*koeff2;
- }
- }
- for (i=size-1; i>0; i--)
- {
- for (int j=i-1; j>=0; j--)
- {
- G[j][i]=0;
- }
- }
- for (i=0; i<size; i++)
- {
- C[i]=B[i]/G[i][i];
- }
- //---POG---------------------------------|
- for (i=0; i<31; i++)
- {
- xT[i]=a+i*(b-(double)a)/30;
- }
- int q=0;
- double t;
- for (t=4; t<=7; t=t+0.1)
- {
- yT[q]=exp(t)/pow(t,3)-pow(sin(t),3);
- q++;
- }
- for (i=0; i<31; i++)
- {
- P=C[n-2]+xT[i]*C[n-1];
- for (k=3; k<=n; k++)
- {
- P=C[n-k]+xT[i]*P;
- }
- Y[i]=P;
- }
- for (i=0; i<31; i++)
- {
- D[i]=fabs(yT[i]-Y[i]);
- }
- //---Vivod-tablicsi-rezyltatov-----------|
- cout<<"F(x) = e^x / x^3 - (sin(x))^3"<<" na intervalle ["<<a<<","<<b<<"]"<<endl;
- cout<<"_____________________________________________________________"<<endl;
- cout<<"No#: X: Y: Y.approx Pogreshnost':"<<endl;
- cout<<"_____________________________________________________________"<<endl;
- for (i=0; i<31; i++)
- {
- printf("#%2d ---- %3.2f ---- %7.6f ---- %8.7f ---- %7.10f\n",i+1,xT[i],yT[i],Y[i],D[i]);
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement