do {
y1=f(x1);
y2=f(x2);
x3=x2-(y2*(x2-x1))/(y2-y1);
x1=x2;
x2=x3;
cout<<"x3 is: "<<x3<<endl;
a=a+1;
}
while (a<=3);
cout<<"the secant root is: "<<x3<<endl;
In this code its supposed to do the secant root findint method where x3 takes on new values 4 times and supposed to output the last value. However, this is the output i am getting.
x3 is: 3.48195
x3 is: 3.48155
x3 is: 3.48155
x3 is: 3.48155
the secant root is: 3.48155
how come the x3 is being the same?
sorry about the code.
do {
y1=f(x1);
y2=f(x2);
x3=x2-(y2*(x2-x1))/(y2-y1);
x1=x2;
x2=x3;
cout<<"x3 is: "<<x3<<endl;
a=a+1;
}
while (a<=3);
cout<<"the secant root is: "<<x3<<endl;