Iterative Process

/*................... Iterative process.........................
.......................Author:-SUDIPTA KUMAR PAIK......................
.......................NUMERICAL METHOD.................*/


#include math.h>
#include stdio.h>
main()
{
int j,i,N;
float sum,nsum,t,oeq[21][2],eq[21][2];
start:
clrscr();
sum=0.0;

printf("\n Enter [0] to terminate input\n\n");

for(i=0; i<21; efficient="); scanf(" i="="0)" power="); scanf(" n="i;" i="0;" t="eq[i][0]*(-1);" j="0;" i="0;"> else
printf("+%.2fX%.0f",oeq[i][0],oeq[i][1]);
}
if(oeq[i][0]<0)
{
printf("%.2fX%.0f",oeq[i][0],oeq[i][1]);
}
}
printf("=0");

printf("\n\n\n Enter First approximation=");
scanf("%f",&nsum);

while(1)
{ stt:
for(i=0; i sum=sum+oeq[i][0]*pow(nsum,oeq[i][1]);
if(nsum==sum)
{ printf("\n\n Solution=%f",sum);
goto ex;
}
else
{ nsum=sum;
goto stt;
}

}
ex:
nsum=sum;
sum=0.0;
for(i=0; i sum=sum+oeq[i][0]*pow(nsum,oeq[i][1]);
printf("\n\n\n f(%.2f)=%.2f",nsum,sum);

getch();
goto start;
}

M M C , M C & etc Random Number Generator

/* ........Random Number Generator.........*/
/*.........Author: Sudipta Kumar paik......*/
/*.........Date: 16/02/2008Time:11:47 pm...*/

#include stdio.h >
#include stdlib.h >
#include dos.h >
#include math.h >

main()
{
int a,b,k,i,j,m,nn,seed,r[50];
char c;


clrscr();

start:
printf("\n\n\n ==========================================================");
printf("\n ==========================================================");
printf("\n Your Choice : ");
printf("\n ==========================================================");
printf("\n [a]= MIXED MULTIPLICATIVE CONGRUENTIAL (M M C) GENERATOR:");
printf("\n [b]= MULTIPLICATIVE CONGRUENTIAL (M C) GENERATOR:");
printf("\n [c]= ADDITIVE CONGRUENTIAL GENERATOR:");
printf("\n [d]= ARITHMATIC CONGRUENTIAL GENERATOR:");
printf("\n [e]= EXIT:");
printf("\n ==========================================================");
printf("\n Choice: ");
c=getchar();
printf("\n ==========================================================");
switch(c)
{ case 'a':

printf("\n Enter the INTEGER Values of a: ");
scanf("%d",&a);
printf("\n Enter the INTEGER Values of b: ");
scanf("%d",&b);
printf("\n Enter the INTEGER Values of m: ");
scanf("%d",&m);

printf("\n Numbers of Random Numbers to be generated n= ");
scanf("%d",&nn);

printf("\n\n [ %d ] Random Numbers are..........\n\n",nn);

r[0]=1;

for(i=1; i<=nn; ++i)
{
r[i]=(a*r[i-1]+b)%m;
printf(" °%4d° ",r[i]);
}

break;

case 'b':

printf("\n Enter the INTEGER Values of a: ");
scanf("%d",&a);
printf("\n Enter the INTEGER Values of m: ");
scanf("%d",&m);
printf("\n Numbers of Random Numbers to be generated n= ");
scanf("%d",&nn);
printf("\n\n [ %d ] Random Numbers are..........\n\n",nn);

r[0]=1;
b=0;

for(i=1; i<=nn; ++i)
{
r[i]=(a*r[i-1]+b)%m;
printf(" °%4d° ",r[i]);
}

break;

case 'c':

printf("\n Enter the INTEGER Values of b: ");
scanf("%d",&b);
printf("\n Enter the INTEGER Values of m: ");
scanf("%d",&m);

printf("\n Numbers of Random Numbers to be generated n= ");
scanf("%d",&nn);

printf("\n\n [ %d ] Random Numbers are..........\n\n",nn);

r[0]=1;
a=1;

for(i=1; i<=nn; ++i)
{
r[i]=(a*r[i-1]+b)%m;
printf(" °%4d° ",r[i]);
}

break;

case 'd':

printf("\n Enter the INTEGER Values of r1: ");
scanf("%d",&r[1]);
printf("\n Enter the INTEGER Values of r2: ");
scanf("%d",&r[2]);
printf("\n Enter the INTEGER Values of m: ");
scanf("%d",&m);

printf("\n Numbers of Random Numbers to be generated n= ");
scanf("%d",&nn);

printf("\n\n [ %d ] Random Numbers are..........\n\n",nn);

for(i=1; i<=nn-2; ++i)
{
r[i+2]=(r[i]+r[i+1])%m;
printf(" °%4d° ",r[i+2]);
}

break;

case 'e':

printf("\n\n\n\t\t\t\t\t\t ............Thanks");
printf("\n\n\n\t\t\t\t\t\t ............Develop By Sudipta");
delay(1400);
exit(1);

}
printf("\n\n\n\t\t\t\t\t\t ............Press Enter");
getch();
goto start;
}

Mid Square Random Number Generator

/* ........Random Number Generator.........*/
/*.........Author: Sudipta Kumar paik......*/
/*.........Date: 16/02/2008Time:11:47 pm...*/

#include stdio.h>
#include stdlib.h>
#include math.h>

main()
{
long int i,s,x,y,z,nd,seed;
int n;

clrscr();

seed=6785;
printf("\n Numbers of Random Numbers to be generated n= ");
scanf("%d",&n);
printf("\n\n [ %d ] Random Numbers are..........\n\n",n);

for(i=1; i<=n; ++i)
{
y=(seed*seed)/100;
z=y/10000;
x=(y-z*10000);
seed=x;
printf(" °%4d° ",x);
}
printf("\n\t\t\t\t\t\t ............Develop By Sudipta");
getch();
}

Star

/*......++++Create Star+++++++++++.....
.......++++AUTHOR: SUDIPTA KUMAR PAIK++++++.......
.....++++Date 17/02/2008++++++++++.......... */
main()
{
int i,j,n;

clrscr();

printf("\n Enter No of Star: ");
scanf("%d",&n);
printf("\n\n");

for(i=1; i<=n; i=i+2)
{

for(j=n; j>=i; j=j-2)
printf(" ");

for(j=1; j<=i; j++)
printf("*");
printf("\n");
}

for(i=n-2; i>=1; i=i-2)
{

for(j=n; j>=i; j=j-2)
printf(" ");

for(j=1; j<=i; j++)
printf("*");
printf("\n");
}

getch();
}

Least Squaqe Regression (Order 1)

/* ......++++++ Least Squre Regression ....++++
......++++++ Order 1 ....++++
......++++++ AUTHOR: SUDIPTA KUMAR PAIK ....++++
......++++++ Numerical Method __3702 ....++++*/


# define eqn 50

main()
{ int q,n,m;
float xy[eqn+1][eqn+2];
float sumxy=0,sumx=0,sumy=0,sumx2=0,x_bar=0,y_bar=0,a0,a1;

do
{
clrscr();

printf("\n\t\tEnter [ 0 ] for EXIT \n");
printf("\n\t\tMaximum[ %d ] \n",eqn);
printf("\n Enter No. of Observation ");

scanf("%d",&n);
if(n==0)
{ printf("\n\n\n\t\tThank you for use this program\n");
printf("\n\t\t.............Prepared By SUDIPTA.............. ");
getch();
exit(1);
}
m=n+1;
for(q=1; q<=n; q++)
{ printf("\n\n Observation %d\n",q);
xy[q][1]=q;
printf("\n x%d=%.f",q,xy[q][1]);
printf("\ty%d=", q);
scanf("%f",&xy[q][2]);
}

for(q=1; q<=n; q++)
{ sumxy=sumxy+xy[q][1]*xy[q][2];
sumx2=sumx2+xy[q][1]*xy[q][1];
sumx=sumx+xy[q][1];
sumy=sumy+xy[q][2];
}
x_bar=sumx/n;
y_bar=sumy/n;

a1=((n*sumxy)-(sumx*sumy))/((n*sumx2)-(sumx*sumx));
a0=y_bar-a1*x_bar;

printf("\n\n\n The Least Square Fit is ");

if(a1<0)
printf("\n\n y=%f%fx",a0,a1);
else
printf("\n\n y=%f+%fx",a0,a1);

getch();

}while(1);

}

Least Square Regression (Order 2)

/*......++++++ Least Squre Regression ++++++......
......++++++ Order 2(Graphics)++++++......
......++++++ AUTHOR: SUDIPTA KUMAR PAIK ++++++......
......++++++ Numerical Method __3721 ++++++......*/

#include graphics.h>
#include stdlib.h>
#include stdio.h>
#include conio.h>
#include math.h>

# define eqn 50

main()
{
int i,xx,yy,qw,q,n,k,j,h,f,d,N=3,xmax, ymax,xlow,ylow;
int gdriver = DETECT, gmode, errorcode;
float xy[eqn+1][3],r[4][5],a[4][5],hh[1000][3];
float sumxi,sumxi2,sumyi,sumxi3,sumxiyi,sumxi4,sumxi2yi,ar[4],x;
char msg[80];

sumxi=sumxi2=sumyi=sumxi3=sumxiyi=sumxi4=sumxi2yi=0;

/* xmax = 639; ymax = 479; */

initgraph(&gdriver, &gmode, "c:\\tc\\bgi");

do
{ sumxi=sumxi2=sumyi=sumxi3=sumxiyi=sumxi4=sumxi2yi=0;
xmax = 639;
ymax = 479;
xlow=169;
ylow=7;

clrscr();
setbkcolor(9);

printf("\n\t\tEnter [ 0 ] for EXIT \n");
printf("\n\t\tMaximum[ %d ] \n",eqn);

printf("\n Enter No. of Observation= ");
scanf("%d",&n);

if(n==0)
{ printf("\n\n\n\t\t\t<<<<===Thank you for use this program===>>>>\n");
printf("\n\t\t\t\t.............Prepared By SUDIPTA.............. ");
getch();
//delay(1200);
exit(1);
}

def1:
setbkcolor(i+1);
printf("\n\n Excute ONE........\n");
printf("\n [1]-INPUT MANUALY");
printf("\n [2]-INPUT RANDOMLY");
printf("\n\n CHOICE= ");
scanf("%d",&q);
printf("\n");
switch(q)
{ case 1:
for(i=1; i<=n; i++)
{ printf("\n Observation [ %d ]\n",i);
printf("\n x%d=",i);
scanf("%f",&xy[i][1]);
printf("\ty%d=", i);
scanf("%f",&xy[i][2]);
}

break;
case 2:
setbkcolor(i+4);
for(i=1; i<=n; i++)
{
xy[i][1]=(rand() % 24);
xy[i][2]=(rand() % 24);
}
break;
default:
setbkcolor(i+5);
printf("\n WRONG SELECTION");
printf("\n Press Enter");
getch();
goto def1;
}



for(i=1; i<=n; i++)
{ sumxi=sumxi+xy[i][1];
sumyi=sumyi+xy[i][2];
sumxiyi=sumxiyi+xy[i][1]*xy[i][2];
sumxi2yi=sumxi2yi+xy[i][1]*xy[i][1]*xy[i][2];
sumxi2=sumxi2+xy[i][1]*xy[i][1];
sumxi3=sumxi3+xy[i][1]*xy[i][1]*xy[i][1];
sumxi4=sumxi4+xy[i][1]*xy[i][1]*xy[i][1]*xy[i][1];
}

r[1][1]=n; r[1][2]=sumxi; r[1][3]=sumxi2; r[1][4]=sumyi;
r[2][1]=sumxi; r[2][2]=sumxi2; r[2][3]=sumxi3; r[2][4]=sumxiyi;
r[3][1]=sumxi2; r[3][2]=sumxi3; r[3][3]=sumxi4; r[3][4]=sumxi2yi;


for(k=1,j=1; j<=N; j++,k++)
{
for(f=1; f<=N; f++)
{ for(h=1; h<=N+1; h++)
a[f][h]=r[f][h];
}

for(i=1; i<=N+1; i++)
r[j][i]=r[j][i]/a[k][k];

for(f=1; f<=N; f++)
{ for(h=1; h<=N+1; h++)
a[f][h]=r[f][h];
}

for(i=1; i<=N; i++)
{ if(i!=j)
{ for(d=1; d<=N+1; d++)
r[i][d]=r[i][d]-a[i][j]*r[j][d];
}
}

}

ar[0]=r[1][4];
ar[1]=r[2][4];
ar[2]=r[3][4];

clrscr();
for(i=1; i<=n; i++)
{ printf(" ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\n Observation [ %2d ]\n",i);
printf(" x%2d=%4.2f ±",i,xy[i][1]);
printf(" y%2d=%4.2f\n",i,xy[i][2]);
}

if(r[2][4]<0 && r[3][4]<0)
{
sprintf(msg," y=%f%fx%fx*x",r[1][4],r[2][4],r[3][4]);
outtextxy(180,420, msg);
}
else if(r[2][4]<0 && r[3][4]>0)
{
sprintf(msg," y=%f%fx+%fx*x",r[1][4],r[2][4],r[3][4]);
outtextxy(180,420, msg);
}
else if(r[2][4]>0 && r[3][4]<0)
{
sprintf(msg," y=%f+%fx%fx*x",r[1][4],r[2][4],r[3][4]);
outtextxy(180,420, msg);
}
else if(r[2][4]>0 && r[3][4]>0)
sprintf(msg," y=%f+%fx+%fx*x",r[1][4],r[2][4],r[3][4]);
outtextxy(180,420, msg);


setbkcolor(6);
setcolor(3);
line(xlow, ymax/2, xmax, ymax/2);
line(xlow-1, ymax/2+1, xmax+1, ymax/2+1);
line(xmax/2+xlow/2, ylow, xmax/2+xlow/2, ymax);
line(xmax/2+xlow/2+1,ylow-1, xmax/2+xlow/2+1, ymax+1);
setcolor(GREEN);
rectangle(xlow,ylow, xmax, ymax);
rectangle(xlow-1,ylow-1, xmax-1, ymax-1);
rectangle(xlow-2,ylow-2, xmax-2, ymax-2);


for(i=1; i<=n; i++)
{ setcolor(10);
xx = ceil(xy[i][1])+235;
yy = ceil(xy[i][2])+235;
circle(xx+xlow,yy,2);
delay(24);
}


x=-125.0;

for(qw=1; qw<=1000 ; qw++)
{
hh[qw][1]=x;
hh[qw][2]=ar[0]+ar[1]*x+ar[2]*x*x;

xx = ceil(hh[qw][1])+235;
yy = ceil(hh[qw][2])+235;

putpixel(xx+xlow,yy,14);

delay(11);

x=x+.25;
}

getch();

}while(1);

}

Least Square Regression

/* ......++++++ Least Squre Regression ++++++......
......++++++ Order 2(Graphics) ++++++......
......++++++ AUTHOR: SUDIPTA KUMAR PAIK ++++++......
......++++++ Numerical Method __3721 ++++++......*/

#include graphics.h>
#include stdlib.h>
#include stdio.h>
#include conio.h>
#include math.h>

# define eqn 50

main()
{
int i,xx,yy,qw,q,n,k,j,h,f,d,N=3,xmax, ymax,xlow,ylow;
int gdriver = DETECT, gmode, errorcode;
float xy[eqn+1][3],r[4][5],a[4][5],hh[1000][3];
float sumxi,sumxi2,sumyi,sumxi3,sumxiyi,sumxi4,sumxi2yi,ar[4],x;
char msg[80];

sumxi=sumxi2=sumyi=sumxi3=sumxiyi=sumxi4=sumxi2yi=0;

/* xmax = 639; ymax = 479; */

initgraph(&gdriver, &gmode, "c:\\tc\\bgi");

do
{ sumxi=sumxi2=sumyi=sumxi3=sumxiyi=sumxi4=sumxi2yi=0;
xmax = 639;
ymax = 479;
xlow=169;
ylow=7;

clrscr();
setbkcolor(9);

printf("\n\t\tEnter [ 0 ] for EXIT \n");
printf("\n\t\tMaximum[ %d ] \n",eqn);

printf("\n Enter No. of Observation= ");
scanf("%d",&n);

if(n==0)
{ printf("\n\n\n\t\t\t<<<<===Thank you for use this program===>>>>\n");
printf("\n\t\t\t\t.............Prepared By SUDIPTA.............. ");
getch();
//delay(1200);
exit(1);
}

def1:
setbkcolor(i+1);
printf("\n\n Excute ONE........\n");
printf("\n [1]-INPUT MANUALY");
printf("\n [2]-INPUT RANDOMLY");
printf("\n\n CHOICE= ");
scanf("%d",&q);
printf("\n");
switch(q)
{ case 1:
for(i=1; i<=n; i++)
{ printf("\n Observation [ %d ]\n",i);
printf("\n x%d=",i);
scanf("%f",&xy[i][1]);
printf("\ty%d=", i);
scanf("%f",&xy[i][2]);
}

break;
case 2:
setbkcolor(i+4);
for(i=1; i<=n; i++)
{
xy[i][1]=(rand() % 24);
xy[i][2]=(rand() % 24);
}
break;
default:
setbkcolor(i+5);
printf("\n WRONG SELECTION");
printf("\n Press Enter");
getch();
goto def1;
}



for(i=1; i<=n; i++)
{ sumxi=sumxi+xy[i][1];
sumyi=sumyi+xy[i][2];
sumxiyi=sumxiyi+xy[i][1]*xy[i][2];
sumxi2yi=sumxi2yi+xy[i][1]*xy[i][1]*xy[i][2];
sumxi2=sumxi2+xy[i][1]*xy[i][1];
sumxi3=sumxi3+xy[i][1]*xy[i][1]*xy[i][1];
sumxi4=sumxi4+xy[i][1]*xy[i][1]*xy[i][1]*xy[i][1];
}

r[1][1]=n; r[1][2]=sumxi; r[1][3]=sumxi2; r[1][4]=sumyi;
r[2][1]=sumxi; r[2][2]=sumxi2; r[2][3]=sumxi3; r[2][4]=sumxiyi;
r[3][1]=sumxi2; r[3][2]=sumxi3; r[3][3]=sumxi4; r[3][4]=sumxi2yi;


for(k=1,j=1; j<=N; j++,k++)
{
for(f=1; f<=N; f++)
{ for(h=1; h<=N+1; h++)
a[f][h]=r[f][h];
}

for(i=1; i<=N+1; i++)
r[j][i]=r[j][i]/a[k][k];

for(f=1; f<=N; f++)
{ for(h=1; h<=N+1; h++)
a[f][h]=r[f][h];
}

for(i=1; i<=N; i++)
{ if(i!=j)
{ for(d=1; d<=N+1; d++)
r[i][d]=r[i][d]-a[i][j]*r[j][d];
}
}

}

ar[0]=r[1][4];
ar[1]=r[2][4];
ar[2]=r[3][4];

clrscr();
for(i=1; i<=n; i++)
{ printf(" ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\n Observation [ %2d ]\n",i);
printf(" x%2d=%4.2f ±",i,xy[i][1]);
printf(" y%2d=%4.2f\n",i,xy[i][2]);
}

if(r[2][4]<0 && r[3][4]<0)
{
sprintf(msg," y=%f%fx%fx*x",r[1][4],r[2][4],r[3][4]);
outtextxy(180,420, msg);
}
else if(r[2][4]<0 && r[3][4]>0)
{
sprintf(msg," y=%f%fx+%fx*x",r[1][4],r[2][4],r[3][4]);
outtextxy(180,420, msg);
}
else if(r[2][4]>0 && r[3][4]<0)
{
sprintf(msg," y=%f+%fx%fx*x",r[1][4],r[2][4],r[3][4]);
outtextxy(180,420, msg);
}
else if(r[2][4]>0 && r[3][4]>0)
sprintf(msg," y=%f+%fx+%fx*x",r[1][4],r[2][4],r[3][4]);
outtextxy(180,420, msg);


setbkcolor(6);
setcolor(3);
line(xlow, ymax/2, xmax, ymax/2);
line(xlow-1, ymax/2+1, xmax+1, ymax/2+1);
line(xmax/2+xlow/2, ylow, xmax/2+xlow/2, ymax);
line(xmax/2+xlow/2+1,ylow-1, xmax/2+xlow/2+1, ymax+1);
setcolor(GREEN);
rectangle(xlow,ylow, xmax, ymax);
rectangle(xlow-1,ylow-1, xmax-1, ymax-1);
rectangle(xlow-2,ylow-2, xmax-2, ymax-2);


for(i=1; i<=n; i++)
{ setcolor(10);
xx = ceil(xy[i][1])+235;
yy = ceil(xy[i][2])+235;
circle(xx+xlow,yy,2);
delay(24);
}


x=-125.0;

for(qw=1; qw<=1000 ; qw++)
{
hh[qw][1]=x;
hh[qw][2]=ar[0]+ar[1]*x+ar[2]*x*x;

xx = ceil(hh[qw][1])+235;
yy = ceil(hh[qw][2])+235;

putpixel(xx+xlow,yy,14);

delay(11);

x=x+.25;
}

getch();

}while(1);

}

GAUSS Jordan

/*..................GAUSS JORDAN.............
...........AUTHOR:-SUDIPTA KUMAR PAIK......
......................N4_11................*/
# define eqn 20

main()
{ int q,w,m,i,j,kkl,ll,n,h,f,k,d,alp=97;
float r[eqn][eqn+1],a[eqn][eqn+1];

do
{
clrscr();

printf("\n Enter [ 0 ] for EXIT \n");
printf("\n Enter No. of Equation ");

scanf("%d",&n);
if(n==0)
{ printf("\n\n\n\t\tThank you for use this program\n");
printf("\n\t\t.............Prepared By SUDIPTA.............. ");
getch();
exit(1);
}
m=n+1;

input:
printf("\n\n [1]-Manual Input ");
printf("\n\n [2]-Random Input ");
printf("\n\n Choice ");
scanf("%d",&kkl);

switch(kkl)
{
case 1:

for(q=1; q<=n; q++)
{ printf("\n\n Eqution %d\n",q);
for(w=1; w<=n; w++)
{ printf("\n Enter %c%d=",alp,w);
scanf("%f",&r[q][w]);
}
printf("\nEnter Constant K%d=", q);
scanf("%f",&r[q][w]);
alp++;
}
break;

case 2:

for(q=1; q<=n; q++)
{ for(w=1; w<=m; w++)
r[q][w]=rand()%(9);
}
break;

default:
printf("\n Wrong Selection");
getch();
goto input;
}

printf("\n\n\n");
for(q=1; q<=n; q++)
{ printf("\n\n");
for(w=1; w<=n; w++)
{ if(r[q][w]<0)
printf("%4.2fX%d",r[q][w],w );
else if(w==1)
printf("%4.2fX%d",r[q][w],w );
else
printf("+%4.2fX%d",r[q][w],w );
}
printf("=%4.2f",r[q][w]);
}

printf("\n\n\n Ú");
for(q=1; q<=8*m; q++)
printf(" ");
printf(" ¿");
printf("\n ³");
for(q=1; q<=8*m; q++)
printf(" ");
printf(" ³");

for(q=1; q<=n; q++)
{ printf("\n ³");
for(w=1; w<=n; w++)
{ printf("%8.4f",r[q][w]);
}
printf("%8.4f ",r[q][w] );
printf("³\n ³");

for(ll=1; ll<=8*m; ll++)
printf(" ");
printf(" ³");

}
printf("\n À");
for(ll=1; ll<=8*m; ll++)
printf(" ");
printf(" Ù");
getch();

for(k=1,j=1; j<=n; j++,k++)
{
for(f=1; f<=n; f++)
{ for(h=1; h<=m; h++)
a[f][h]=r[f][h];
}

for(i=1; i<=m; i++)
r[j][i]=r[j][i]/a[k][k];

for(f=1; f<=n; f++)
{ for(h=1; h<=m; h++)
a[f][h]=r[f][h];
}

for(i=1; i<=n; i++)
{ if(i!=j)
{ for(d=1; d<=m; d++)
r[i][d]=r[i][d]-a[i][j]*r[j][d];
}
}

}

printf("\n\n\n\n\tResult Determinant.........\n");
printf("\n\n Ú");
for(q=1; q<=8*m; q++)
printf(" ");
printf(" ¿");
printf("\n ³");
for(q=1; q<=8*m; q++)
printf(" ");
printf(" ³");

for(q=1; q<=n; q++)
{ printf("\n ³");
for(w=1; w<=n; w++)
printf("%8.4f",r[q][w]);
printf("%8.4f ",r[q][w] );
printf("³\n ³");

for(ll=1; ll<=8*m; ll++)
printf(" ");
printf(" ³");

}
printf("\n À");
for(ll=1; ll<=8*m; ll++)
printf(" ");
printf(" Ù");

printf("\n\n Result.........\n");
for(q=1; q<=n; q++)
printf("\n\n X%d=%.5f",q,r[q][m]);

getch();
}while(1);

}

False Position Method

/*....................... False Position Method.........................

.......................Author:-SUDIPTA KUMAR PAIK......................

.......................NUMERICAL METHOD.................*/



#include

#include

#include

main()

{ int i,N,x;

float fxlr,xr_old,xu,xl,xr,fxl,fxr,fxu,eq[21][2];

clrscr();



printf("\n Enter [0] to terminate input\n\n");



for(i=0; i<21; i++)

{

printf("\n Enter Co-efficient=");

scanf("%f",&eq[i][0]);

if(eq[i][0]==0)

break;

printf("\n Enter Power=");

scanf("%f",&eq[i][1]);

}





N=i;

printf("\n\n\nf(X)=");

for(i=0; i<0)

printf("%.2fX%.0f",eq[i][0],eq[i][1]);

if(eq[i][0]>0)

printf("+%.2fX%.0f",eq[i][0],eq[i][1]);

}



ss:

printf("\n\n\n Enter Lower value xl=");

scanf("%f",&xl);

printf("\n Enter Upper value xu=");

scanf("%f",&xu);



fxl=fxu=fxr=xr=0.0;



for(i=0; i
{ fxl=fxl+eq[i][0]*pow(xl,eq[i][1]);

fxu=fxu+eq[i][0]*pow(xu,eq[i][1]);

}



fxlr=fxl*fxu;



if(fxlr>-1)

{ printf("\n Upper Limit & Lower Limit is Not Correct");

goto ss;

}

else if(fxl==0)

goto end;

else if(fxu==0)

goto end;





xrl:

xr_old=xr;

xr=xu-((fxu*(xl-xu))/(fxl-fxu));

fxl=fxu=fxr=0.0;



for(i=0; i
{ fxl=fxl+eq[i][0]*pow(xl,eq[i][1]);

fxr=fxr+eq[i][0]*pow(xr,eq[i][1]);

fxu=fxu+eq[i][0]*pow(xu,eq[i][1]);

}



fxlr=fxl*fxr;



if((sqrt(pow(xr_old-xr,2)))<0.00005)

goto end;



else if(fxlr<0)

{ xu=xr;

goto xrl;

}

else if(fxlr>0)

{ xl=xr;

goto xrl;

}





end:

xr=xl;

xr=xu;

fxr=0;

printf("\n\n\n ROOT=%f",xr);

for(i=0; i
fxr=fxr+eq[i][0]*pow(xr,eq[i][1]);

printf("\n\n f(%f)=%f",xr,fxr);



getch();

}

Bisection Method

/*....................... Bisection Method.........................

.......................Author:-SUDIPTA KUMAR PAIK......................

.......................NUMERICAL METHOD.................*/



#include < iostream.h >

#include < math.h >

#include < stdio.h >

#include < conio.h >

main()

{ int i,N;

float fxlr,xu,xl,xr,fxl,fxr,fxu,eq[21][2];

clrscr();



fxl=0.0;

fxu=0.0;

fxr=0.0;



printf("\n Enter [0] to terminate input\n\n");



for(i=0; i<21; i++)

{

printf("\n Enter Co-efficient=");

scanf("%f",&eq[i][0]);

if(eq[i][0]==0)

break;

printf("\n Enter Power=");

scanf("%f",&eq[i][1]);

}





N=i;

printf("\n\n\nf(X)=");

for(i=0; i
printf("+%.2fX%.0f",eq[i][0],eq[i][1]);



ss:

printf("\n\n\n Enter Lower value xl=");

scanf("%f",&xl);

printf("\n Enter Upper value xu=");

scanf("%f",&xu);





for(i=0; i
{ fxl=fxl+eq[i][0]*pow(xl,eq[i][1]);

fxu=fxu+eq[i][0]*pow(xu,eq[i][1]);

}



// fxlr=fxl*fxu;



/*if(fxlr>0)

{ printf("\n Upper Limit & Lower Limit is Not Correct");

goto ss;

} */

if(fxl==0)

goto endxl;

else if(fxu==0)

goto endxu;



xrl:

xr=(xl+xu)/2;



for(i=0; i
{ fxl=fxl+eq[i][0]*pow(xl,eq[i][1]);

fxr=fxr+eq[i][0]*pow(xr,eq[i][1]);

}



fxlr=fxl*fxr;



if(fxlr<0)

{ xu=xr;

fxl=0.0;

fxu=0.0;

fxr=0.0;



goto xrl;

}

else if(fxlr>0)

{ xl=xr;

fxl=0.0;

fxu=0.0;

fxr=0.0;



goto xrl;

}

else if (fxlr<0.0005 && fxlr>-0.0005 )

printf("\n\n\n ROOT=%.2f",xr);

goto end;





endxl:

xr=xl;

printf("\n\n\n ROOT=%.2f",xl);

goto end;

endxu:

xr=xu;

printf("\n\n\n ROOT=%.2f",xu);



/* printf("\n\n\nf(%.2f)=%.2f",xl,fxl);

printf("\n\n\nf(%.2f)=%.2f",xr,fxr); */



end:

for(i=0; i
fxr=fxr+eq[i][0]*pow(xr,eq[i][1]);

printf("\n\nf(%.2f)=%.2f",xr,fxr);



getch();

}