[Erledigt] Gauß-Seidel-Verfahren

Neue Frage »

MatheKind Auf diesen Beitrag antworten »
[Erledigt] Gauß-Seidel-Verfahren
Hallo,
irgendwie kriege ich das Gauß-Seidel-Verfahren nicht richtig implementiert.

https://de.wikipedia.org/wiki/Gau%C3%9F-Seidel-Verfahren

code:
1:
2:
3:
12x + 2y + 3z  =  18
  x - 3y + 12z =  6
 -x + 8y + 2z  = -32

code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    double x = 0.0;
    double y = 0.0;
    double z = 0.0;

    for (int i = 0; i < 30; ++i) {
        x = (1/12.0) * (18 - (2 * y + 3 * z));
        y = -(1/3.0) * (6 -(x + 12 * z));
        z = (1/ 2.0) * (-32 - (-x + 8 * y));

        cout << "Schritt(" << i << "): x: " << x << ", y: " << y << ", z: " << z << endl;
    }

    return 0;}

Die Beträge werden bei mir immer größer anstatt zu konvergieren. verwirrt

code:
1:
2:
3:
4:
5:
6:
7:
Schritt(0): x: 1.5, y: -1.5, z: -9.25
Schritt(1): x: 4.0625, y: -37.6458, z: 136.615
Schritt(2): x: -26.3793, y: 535.665, z: -2171.85
Schritt(3): x: 455.185, y: -8537.67, z: 34362.3
Schritt(4): x: -7166.13, y: 135058, z: -543833
Schritt(5): x: 113450, y: -2.13752e+06, z: 8.60678e+06
Schritt(6): x: -1.79544e+06, y: 3.38286e+07, z: -1.36212e+08

Jemand eine Ahnung?
MatheKind Auf diesen Beitrag antworten »

Ok, habe die Matrix auf diagonaldominanz umgestellt und nun funktioniert's. smile
Neue Frage »
Antworten »



Verwandte Themen

Die Beliebtesten »
Die Größten »
Die Neuesten »