      program gauss
c Gauss-Seidel relaksasjon      
      dimension volt(0:1000),cond(0:999)
      dimension resi(0:999)
c Tilfelding tall initialisering 
      rinv=0.5/2147483647.
      rold=0.
      ibm=1927
      do i=1,1000
      ibm=ibm*16807
      enddo
c Genererer de 1000 konduktansene
      do i=0,999      
      ibm=ibm*16807
      cond(i)=ibm*rinv+0.5
      enddo
      do i=1,999 
      resi(i)=1./(cond(i-1)+cond(i))
      enddo
c Presisjonskriterium
      pres=2.e-4
c Initialiserer spenningene
      do i=0,1000      
      volt(i)=float(i)/1000
      enddo
c Iterasjonen
      do ite=1,1000000
      do i=1,999 
      volt(i)=(cond(i-1)*volt(i-1)+cond(i)*volt(i+1))*resi(i)
      enddo
      eps=0.
      do i=1,999 
      eps=eps+(cond(i-1)*volt(i-1)+cond(i)*volt(i+1)
     &   -(cond(i-1)+cond(i))*volt(i))**2
      enddo
      eps=sqrt(eps)
      write(*,*) ite,eps
      if(eps.lt.pres) goto 200
      enddo
c Ferdig
200   continue
      end
