wap to implement bisection method to find the root of (X)*log10(X)-1.2.



#define f(x) (x)*log10(x)-1.2
#include<stdio.h>
# include<math.h>
 main()
{
float i,a,b,c,t=0;
for(i=0;;i++)
{
if(f(i)>0&&f(i+1)<0)
{
a=i;b=i+1;break;}
if((f(i)<0)&&(f(i+1)>0))
{
a=i+1;b=i;break;}
}
for(i=0;;i++)
{
c=(a+b)/2;
if(f(c)>0)
a=c;
else
b=c;
if(fabs(c-t)<=.00005)
break;
t=c;
}
printf("\nthe root is %f",c);
}

3 comments:

Implemet Stack in python

  class Stack : def __init__ ( self , data ): self . stack = [] if ( data ): self . stack . append ( da...