• Uncategorized

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

Source Code:

///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;
}
SHARE Numerical Methods: Solution of non-linear equation by using Secant method in C

You may also like...


Warning: Undefined array key 0 in /www/wwwroot/followtutorials.com/wp-content/themes/hueman/single.php on line 9

Warning: Attempt to read property "cat_name" on null in /www/wwwroot/followtutorials.com/wp-content/themes/hueman/single.php on line 9

Warning: Undefined array key 0 in /www/wwwroot/followtutorials.com/wp-content/themes/hueman/single.php on line 14

Warning: Attempt to read property "category_parent" on null in /www/wwwroot/followtutorials.com/wp-content/themes/hueman/functions.php on line 37

Warning: Undefined array key 0 in /www/wwwroot/followtutorials.com/wp-content/themes/hueman/single.php on line 15

Warning: Attempt to read property "category_parent" on null in /www/wwwroot/followtutorials.com/wp-content/themes/hueman/single.php on line 15
Share