#include <stdio.h> #include <math.h> double f(double x) { return pow(x,2)-4*x-10; //Given equation may will be changed } int main() { float x1,x2,x3,f1,f2,E; printf("Enter initial points X1 and X2: "); scanf("%f %f",&x2,&x3); printf("Enter the tolerance value: "); scanf("%f",&E); do { x1 = x2; x2 = x3; f1 = f(x1); f2 = f(x2); x3 = (f2*x1 - f1*x2)/(f2-f1); } while(fabs((x3-x2)/x3)>E); printf("Root is: %.2f\n",x3); return 0; } //Reference : Nemerical Methods by E Balagurusamy (2016-2017) pages (153 -154)
Thursday, 16 November 2017
Secant Method
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment