# Numerical Methods: Solution of non-linear equation by using Secant method in C

**Source Code:**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ///solution of non linear equations using secant method #include<stdio.h> #include<math.h> float f(float x){ return (pow(x,5) - 3*pow(x,3)-1); } int main(){ float a, b, c; int count = 0; printf("Enter the initial value of a: "); scanf("%f", &a); printf("Enter the initial value of b: "); scanf("%f", &b); while(1){ count++; c = (a*f(b)-b*f(a))/(f(b)-f(a)); if(c==b){ break; } if(count>=20){ break; } a = b; b = c; } printf("\nThe root after %d iteration is %.7f\n",count, c); return 0; } |

## Recent Comments