Skip to main content

JACOBI AND GAUSS-SIEDEL SCHEMES


##The formulas and the iteration procedure
##below are taken from the Devies Book
##Eqn 5.89
##Constants and Initializations
dx=1E-3; ##Increment in x.
c1=1-2.5*dx; ## c1,c2,c3,c4 are constants in Eqn.5.89
c2=1+2.5*dx;
c3=-10*dx*dx;
c4=1/(2+c3);
## Set up the initial profile
x=0.0:0.01:1.0;
yold=0:100;
hold on
plot(x,yold);
xlabel('x');
ylabel('y');
##Impose the boundary conditions
Nsteps=1000;
yoldJac=yold; ## old y values for Jacobi Iteration Scheme
yoldGauSied=yold; ## old y values for Gauss-Siedel Scheme
ynewJac=yoldJac; ## new y values for Jacobi Iteration Scheme
ynewGauSied=yoldGauSied; ## new y values for Gauss-Siedel Scheme
for n=1:Nsteps
for i=2:100
ynewJac(i)=c4*(c1*yoldJac(i+1)+c2*yoldJac(i-1)+c3*x(i));
ynewGauSied(i)=c4*(c1*yoldGauSied(i+1)+c2*ynewGauSied(i-1)+c3*x(i));
endfor
yoldJac=ynewJac;
yoldGauSied=ynewGauSied;
endfor
plot(x,ynewJac,'g*',x,ynewGauSied,'m@');
title('y vs x');
xlabel('x');
ylabel('y');
legend('y(initial)','Jacobi','Gauss-Siedel');
axis([0,1.5]);
hold off
save -text JACOBIGAUSSSIEDEL.dat
print ('-dpsc','JACOBIGAUSSSIEDEL.ps')

Comments

Popular posts from this blog

PHYSICS MACHINE

Physics Machine  Ümit Alkuş  Abstract Physics machine is a software which does physics like a physicist. First, all the things human being has developed so far, for doing physics, will be available to this machine. Secondly, all the consistent theories, successful experiments, and published articles will be included into this machine in the form of traced and readable knowledge, in other words, this machine can read and understand these all. Finally, as the last target, this machine can observe the universe and physical events with the aim of creating theories and physical laws.  METU, Physics Department, 06800, Ankara, Turkey   Keywords: Artificial Intelligence, Machine Learning, Data Mining, Artificial Physicist   Introduction There are approximately millions of articles over physics, huge collection of very successful theories, and physics books. In the earth, no physicist could have attempted to read and understand these accumulations since it re...