Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- float f(float x, float a,float b,float c)
- {
- return ((a*x*x)+(b*x)+c);
- }
- float g(float x, float a,float b,float c)
- {
- return ((((-a)*x*x)-c)/b);
- }
- int main()
- {
- float a, b, c, root;
- int it, count=0;
- cout<<"Enter The Value of a : ";
- cin>>a;
- cout<<"Enter The Value of b : ";
- cin>>b;
- cout<<"Enter The Value of c: ";
- cin>>c;
- cout<<"Enter The Number of iterations : ";
- cin>>it;
- int X[it];
- cout<<"Enter The Initial Guess : ";
- cin>>X[0];
- for(int i=0; i<=it; i++){
- X[i+1] = g(X[i],a,b,c);
- if(X[i+1] > X[i])
- count++;
- else
- count = 0;
- if(count > 3)
- break;
- }
- cout<<"System has Monotone divergence"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement