Skip to main content
JustPaste
HomeAboutDonateContactTerms of UsePrivacy Policy

© 2026 Just Paste. All rights reserved.

Made with ❤️ by TakiDev

Untitled Page | JustPaste.app
Publish about 1 month ago41 views

#include<iostream>

#include<cmath>

#define EPS 0.00001

using namespace std;

float g(float x){

return 5+.5*sin(x);

}

int main(){

float x0, x1;

int n=1;

cout<<"Enter an inital point x0\n";

cin>>x0;

x1=g(x0);

while(fabs((x1-x0)/x1)>EPS){

n++;

x0=x1;

x1=g(x0);

if(g(x1)==x1) break;

}

cout<<"The approximation root of the given function is " << x1 << " with " << n <<" number of interation";

}