Sunday, September 28, 2008

Jacobi Method Algorithm.

flag =1;

for(i=0; i < n;i++0)
{
t[i]=b[i]/a[i][i];
x[i]=t[i];
}

while ( flag==1)
{
for(i=0;i < n;i++)
{

x[i]=b[i]/a[i][i] ;

for(j=0; j < n;j++)

{
if(i != j)
x[i] - =(t[j]*a[i][j])/a[i][i];
else
continue;
}

}
for(i=0; i < n;i++)
{
if(x[i] - t[i] > = 0.005)
{
t[i]=x[i];
flag==1;
}
else
flag==0;
}

}

No comments: