0% found this document useful (0 votes)
22 views

Program No. 1: Program:Solution of Non-Linear Equations Using Bisection Method

This program uses the bisection method to solve non-linear equations. It takes user input for the bounds a and b of the function, the allowed error, and maximum number of iterations. It then iteratively bisects the interval and checks if the function values at the endpoints have opposite signs. If so, it updates the bounds and finds the new root. This continues until the absolute difference between successive roots is less than the allowed error or the maximum iterations are reached.

Uploaded by

Milo Yadav
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Program No. 1: Program:Solution of Non-Linear Equations Using Bisection Method

This program uses the bisection method to solve non-linear equations. It takes user input for the bounds a and b of the function, the allowed error, and maximum number of iterations. It then iteratively bisects the interval and checks if the function values at the endpoints have opposite signs. If so, it updates the bounds and finds the new root. This continues until the absolute difference between successive roots is less than the allowed error or the maximum iterations are reached.

Uploaded by

Milo Yadav
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

PROGRAM NO.

1
Program:Solution of non-linear equations using Bisection method.
#include<stdio.h>
#include<stdio.h>
#include <math.h>
#include<conio.h>
#define f(x) ((x)*log10(x) -1.2)
void bisect(float a,float b,float *x,int itr)
{
*x=(a+b)/2;
printf("After %d iterations value of root=%10.7f\n",itr,*x);
}
void main()
{
int itr=1,maxitr;
float a,b,x,x1,AE;
printf("Enter the values of a, b, Allowed error, max iterations allowed\n");
scanf("%f%f%f%d",&a,&b,&AE,&maxitr);
printf("\n-----------------------------------------------------------------\n");
bisect(a,b,&x,itr);
do
{
if(f(a)*f(x)<0)
b=x;
else
a=x;
itr++;
bisect(a,b,&x1,itr);
if(fabs(x1-x)<AE)
{
printf("\nAfter %d iterations,the root X=%10.7f\n",itr,x1);
getch();
}
x=x1;
}
while(itr<maxitr);
printf("Max no of iterations allowed are insufficient");
getch();
}

2288847

Pradeep Yadav

ECE-B IV

Output:

2288847

Pradeep Yadav

ECE-B IV

You might also like