Search:

Submit Article

# SECANT METHOD USING e(x)-3x

Posted By: Leah Hughes     Category: C Programming     Views: 6579

## Code for SECANT METHOD USING e(x)-3x in C Programming

```#include<stdio.h>
#include<conio.h>
#include<math.h>
#define epsil 0.00001

int p,c[10];

void appro();
voidfalse(float,float,float,float);

void main()
{
clrscr();
appro();
getch();
}

voidfalse(float x1,float x2,float fx1,float fx2)
{
float x3,fx3,temp;
int n=1;
printf("******************************************************************\n");
printf("\nIt   x1        fx1        x2         fx2        x3         fx3\n");
printf("******************************************************************\n");
do
{
temp=x3;
x3=(((x1*fx2)-(x2*fx1))/(fx2-fx1));
fx3=(exp(x3)-(3*(x3)));
x1=x2;
fx1=fx2;
x2=x3;
fx2=fx3;
printf("%d   %.4f    %.4f     %.4f    %.4f    %.4f     %.4f\n",n,x1,fx1,x2,fx2,x3,fx3);
n=n+1;
}while((fabs(temp-x3)>=epsil)&&(fx3!=0));
printf("\n\t\t********************\n");
printf("\n\t\tThe root is %.4f\n",x3);
printf("\t\t********************\n");
}

void appro()
{
float x1,x2,x3,fx1,fx2,fx3;
scanf("%f",&x1);
scanf("%f",&x2);
fx1=(exp(x1)-(3*(x1)));
fx2=(exp(x2)-(3*(x2)));
false(x1,x2,fx1,fx2);
}
```
Share:

Didn't find what you were looking for? Find more on SECANT METHOD USING e(x)-3x Or get search suggestion and latest updates.

 Leah Hughes author of SECANT METHOD USING e(x)-3x is from London, United Kingdom. View All Articles

 Please enter your CommentComment should be atleast 30 Characters.Please put code inside [Code] your code [/Code]. No Comment Found, Be the First to post comment!