resource Jacobi() const int n = 10 const int f = 5 int numiter real a [0:n+1,0:n+1], b [0:n+1,0:n+1] procedure compute_row (int i) { for [j=1 to n] { b[i,j] = (a[i-1,j] + a[i+1,j]+ a[i,j-1]+a[i,j+1]) /4 } } procedure update_row (int i) { for [i=1 to n] { for [j=1 to n] { a[i,j]= b[i,j]} } } # Initialisiere Felder a und b for [i=0 to (n+1)] { for [j=0 to (n+1)] { a[i,j] = 100.0; b[i,j]= a[i,j] } } # Randpunkte von a belegen for [i=0 to n+1] { a[i,0] = 0 } # Anzahl notwendiger Iterationen bestimmen numiter = f * n * n / 2; writes("Anzahl notwendiger Iterationen: ", numiter) write() # Iteration zur Bestimmung der Werte im stabilen Zustand for [k=1 to numiter] { # 1. Phase : Neuberechnung der Werte co [i=1 to n] compute_row(i) oc # 2. Phase : Update co [i=1 to n] update_row(i) oc } # Ausgabe des Ergebnisses write("Ausgabe der Ergebnismatrix"); write() for [i=1 to n] { for [j=1 to n] { writes(b[i,j]," ") }; write() } end