| |
|
|
p.specht
| The Gauss-Seidel-Iteration is a zyklisches take action to Solution linearer Gleichungssysteme (LGS) the general shape A*x = b. These can schrittweise solve, because one multiple rechnet: x(new) = x(old) - Korr, with Korrekturvektor Korr = A*x(old) - b
it deals itself means circa a Fehlerrückkopplung. eachone Passage correct the Result a little bit. one begins thereby with geratenen Values, and something Happiness comes one Error very near zero out.
The Gauß-Seidel-Iteration is Specifically appropriate to badly konditionierte Gleichungsysteme (the are such, with them itself Rundungs- and Binärübersetzungsfehler mutual join would). tappt im dunkeln reacted too less sensitive on fehlerbehaftete Koeffizienten as the Gauß-take action. Natürlicher disadvantage of Iterationsverfahren is, that the Rechenzeit vastly larger is as with direct Algorithms.
Fehlermeldungen should improved go, because the case "Singuläre Matrix" lying with Division through zero namely not always to. it was however meaningfully, at least this Error once abzufangen.
Window Title "LGS-Solution through Gauß-Seidel-Iteration"
' fountain: https://www.rhirte.de/vb/gleichsys.htm#seidel
' from Visual Basic in XProfan 11.2a Translated of
' P. woodpecker 2012-04. Demoware! No How always geartete Liability,
' usage solely on own risk the Anwenders!
'
' TESTMATRIX DEFINIEREN:
Var n&=4
Var e!=val("1e-9")
Declare A![n&,n&+1],x![n&],it$
' Koeffizienten + rights Page:
A![1,1]=1 :A![1,2]=0 :A![1,3]=0 :A![1,4]=0 : A![1,5]=10' = b1
A![2,1]=0 :A![2,2]=1 :A![2,3]=0 :A![2,4]=0 : A![2,5]=20' = b2
A![3,1]=0 :A![3,2]=0 :A![3,3]=1 :A![3,4]=0 : A![3,5]=30' = b3
A![4,1]=0 :A![4,2]=0 :A![4,3]=0 :A![4,4]=1 : A![4,5]=40' = b4
Start:
Declare xp![n&],R!,s!,T!,i&,j&,num&
WhileLoop n&:i&=&Loop
x![i&] = 5' Startvektor with of/ one first Ausgangslösung
EndWhile
Repeat
WhileLoop n&
i&=&Loop
s!=0
WhileLoop i&-1
j&=&Loop
s!=s!+A![i&,j&]*xp![j&]
EndWhile
T!=0
WhileLoop i&+1,n&
j&=&Loop
T!=T!+A![i&,j&]*X![j&]
EndWhile
if A![i&,i&]=0
print " Singuläre Matrix!"
it$="sing"
BREAK
Endif
xp![i&]=(A![i&,n&+1]-s!-T!) / A![i&,i&]
EndWhile
case it$="sing":break
s!=0
WhileLoop n&:i&=&Loop
R!=X![i&]-xp![i&]
s!=s!+ R!*R!
X![i&]=xp![i&]
EndWhile
num& = num& + 1
Until Sqr(s!/(n&-1)) < e!
Case it$<>"":Goto "Stop"
' spending:
print "\n Result found in ";num&;" Durchläufen:"
WhileLoop n&
i&=&Loop
print " x"+st$(i&)+" = ";x![i&]
EndWhile
Stop:
print
WaitInput
End
|
|
|
| XProfan 11Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 04/17/21 ▲ |
|
|
|