Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int It=6;
- double v;
- // Fixed POINT METHOD
- double x,y,z;
- double First_Equation (){
- // return 2-(x*x);
- return 5/x;
- }
- double Second_Equation (){
- return (y*y)+y-5;
- }
- double Third_Equation (){
- return (z+(5/z))/2;
- }
- void solve(){
- int ok=0,i=0;
- v=0;
- while(true){
- long double F=First_Equation();
- cout<<"Iteration "<<++i<<": "<<F<<"\n";
- x=F;
- if(It==ok) break;
- if(v-F==0){ break;goto S;}
- v=F;
- ok++;
- }
- cout<<"\n\n";
- ok=0,v=0,i=0;
- while(true){
- long double F=Second_Equation();
- cout<<"Iteration "<<++i<<": "<<F<<"\n";
- y=F;
- if(It==ok) break;
- if(v-F==0){ break;goto S;}
- v=F;
- ok++;
- }
- cout<<"\n\n";
- ok=0,v=0,i=0;
- while(true){
- long double F=Third_Equation();
- cout<<"Iteration "<<++i<<": "<<F<<"\n";
- z=F;
- if(It==ok) break;
- if(v-F==0){ break;goto S;}
- v=F;
- ok++;
- }
- S:
- cout<<"\n"<<"Solution: "<<v<<"\n";
- }
- int main()
- {
- cin>>x;
- cin>>y;
- cin>>z;
- solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement