Anda di halaman 1dari 5

Muhammad ilham syafei

1910912035

c Program Gauss Seidel

real a,b,c,d,e,f,g,h,i,j,o,p,q,r,s,t,u,v,w,x

integer n

o=0.0

p=0.0

q=0.0

r=0.0

s=0.0

t=0.0

u=0.0

v=0.0

w=0.0

x=0.0

write(*,*)'------------------------------------------------------'

write(*,*)'diketahui suatu persamaan'

write(*,*)'2o+4p-q+3r-s+4t+2u-v-3w+x= 39'

write(*,*)'o+p-2q-3r+s-3t+u-5v+w+2x= -14'

write(*,*)'5o+2p+2q+2r-5s-3t+3u-v+2w+5x= 48'

write(*,*)'5o+5p+5q-10r+5s-3t+3u+v-2w+x= 34'

write(*,*)'3o-6p-3q+r-2s-4t+3u+3v-w+4x= -8'

write(*,*)'6o-3p+2q-5r-2s+4t-u+3v-5w+3x= -9'
Muhammad ilham syafei
1910912035

write(*,*)'o+2p+2q+5r+s+2t-5u+3v-5w-6x= -26'

write(*,*)'2o+p-q-2r+4s+2t+5u-3v-6w+5x= 37'

write(*,*)'4o+4p-4q-4r-4s+4t+4u-4v-4w+4x= 32'

write(*,*)'3o+4p-5q-2r+6s+4t-6u-2v-2w+x= 23'

write(*,*)' '

write(*,*)' '

write(*,*)'Input jumlah maximal iterasi:'

read(*,*)m

n=0

5 n=n+1

if(n.eq.m) then

go to 6

endif

a=o

b=p

c=q

d=r

e=s

f=t

g=u

h=v

i=w
Muhammad ilham syafei
1910912035

j=x

o=(39-4*p+q-3*r+s-4*t-2*u+v+3*w-x)/2.0

p=(-14-o+2*q+3*r-s+3*t-u+5*v-w-2*x)/1.0

q=(48-5*o-2*p-2*r+5*s+3*t-3*u+v-2*w-5*x)/2.0

r=(34-5*o-5*p-5*q-5*s+3*t-3*u-v+2*w-x)/(-10.0)

s=(-8-3*o+6*p+3*q-r+4*t-3*u-3*v+w-4*x)/(-2.0)

t=(-9-6*o+3*p-2*q+5*r+2*s+u-3*v+5*w-3*x)/4.0

u=(-26-o-2*p-2*q-5*r-s-2*t-3*v+5*w+6*x)/(-5.0)

v=(37-2*o-p+q+2*r-4*s-2*t-5*u+6*w-5*x)/(-3.0)

w=(32-4*o-4*p+4*q+4*r+4*s-4*t-4*u+4*v-4*x)/(-4.0)

x=(23-3*o-4*p+5*q+2*r-6*s-4*t+6*u+2*v+2*w)/1.0

6 continue

if( real((o-a)/o) .GT. 0.001) then

goto 5

endif

if( real((p-b)/p) .GT. 0.001) then

goto 5

endif
Muhammad ilham syafei
1910912035

if( real((q-c)/q) .GT. 0.001) then

goto 5

endif

if( real((r-d)/r) .GT. 0.001) then

goto 5

endif

if( real((s-e)/s) .GT. 0.001) then

goto 5

endif

if( real((t-f)/t) .GT. 0.001) then

goto 5

endif

if( real((u-g)/u) .GT. 0.001) then

goto 5

endif

if( real((v-h)/v) .GT. 0.001) then


Muhammad ilham syafei
1910912035

goto 5

endif

if( real((w-i)/w) .GT. 0.001) then

goto 5

endif

if( real((x-j)/x) .GT. 0.001) then

goto 5

endif

write(*,*)'nilai o adalah:', o

write(*,*)'nilai p adalah:', p

write(*,*)'nilai q adalah:', q

write(*,*)'nilai r adalah:', r

write(*,*)'nilai s adalah:', s

write(*,*)'nilai t adalah:', t

write(*,*)'nilai u adalah:', u

write(*,*)'nilai v adalah:', v

write(*,*)'nilai w adalah:', w

write(*,*)'nilai x adalah:', x

stop

end

Anda mungkin juga menyukai