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>
- double X[100],Y[100], x_0, x_1, y_0, y_1, d, de, z;
- int i, l, iter;
- int a=4;
- int b=7;
- double eps=0.0001;
- //======================================================|
- double Function(double x)
- {
- double F=0;
- F=exp(x)/pow(x,3)-pow(sin(x),3)-2;
- return F;
- }
- //======================================================|
- int main()
- {
- //__Zapolnenie__massiva__iksov__i__igrekov____________|
- for (i=0; i<21; i++)
- {
- X[i] = a+i*double(b-a)/20;
- Y[i] = Function(X[i]);
- }
- //__Vivod__Tablicsi___________________________________|
- cout<<"______________________________________________________________"<<endl;
- printf("X\tY\n");
- cout<<"______________________________________________________________"<<endl;
- for (i=0; i<21; i++)
- {
- printf("%1.1f\t%5.3f\n",X[i],Y[i]);
- }
- //__Metod__Vegsteina__________________________________|
- l=0;
- for (i=0; i<21; i++)
- {
- if (Y[i]*Y[i+1]<0)
- {
- l++;
- x_0=X[i];
- x_1=X[i+1];
- y_0=Y[i];
- y_1=Y[i+1];
- iter=0;
- do
- {
- iter++;
- d=x_1-x_0;
- z=x_1-y_1*d/(y_1-y_0);
- de=fabs(x_1-z);
- x_0=x_1;
- x_1=z;
- y_0=y_1;
- y_1=Function(z);
- }
- while (de<eps || iter>100);
- }
- }
- cout<<"x_0["<<l<<"]= "<<z<<endl;
- cout<<"Iter= "<<iter<<endl;
- cout<<"l= "<<l<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement