Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream.h>
- #include <math.h>
- double Func(double);
- double dFunc(double);
- double func(double,double); // ïðîòîòèïû
- double dfunc(double,double);
- double getMaxFunc(double,double,double);
- double getQ(double,double,double,double);
- double Func(double x)
- {
- return exp(1.5-4*cos(2*x))-25*x;
- }
- double dFunc(double x)
- {
- return 8*sin(2*x)*exp(1.5-4*cos(2*x))-25;
- }
- double func(double x, double mu)
- {
- return x-mu*Func(x);
- }
- double dfunc(double x, double mu)
- {
- return 1-mu*dFunc(x);
- }
- double getMaxFunc(double a, double b, double eps)
- {
- double max = a;
- double count = a; // count - ñ÷åò÷èê
- do
- {
- count = count + eps;
- if(dFunc(max)<dFunc(count))
- max = count;
- } while(count<=b);
- return max;
- }
- double getQ(double a, double b, double mu, double eps)
- {
- double max = a;
- double count = a;
- do
- {
- count = count + eps;
- if(dfunc(max,mu)<dfunc(count,mu))
- max = count;
- } while(count<=b);
- return max;
- }
- int main()
- {
- double a,b,eps;
- cout<<"Vvedite a,b,epsilon"<<endl;
- cin>>a>>b>>eps;
- for(int i=0; i<1; i++)
- {
- double mu = 1/getMaxFunc(a,b,eps);
- double q = getQ(a,b,mu,eps);
- double x,y = a;
- for(int i=0; i<10; i++)
- {
- x = y;
- y = func(x,mu);
- cout<<y<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement