s(i)) THEN s(i) = ABS(matrix(i,j)) END IF CALL GaussElimination(matrix, b, x, s, n) 자료 입력단계 Define scale factor si for each row 가우스 소거법 서브루틴 호출"> s(i)) THEN s(i) = ABS(matrix(i,j)) END IF CALL GaussElimination(matrix, b, x, s, n) 자료 입력단계 Define scale factor si for each row 가우스 소거법 서브루틴 호출">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

Gauss Elimination with scaled partial pivoting

Similar presentations


Presentation on theme: "Gauss Elimination with scaled partial pivoting"— Presentation transcript:

1 Gauss Elimination with scaled partial pivoting
재료수치해석 Gauss Elimination with scaled partial pivoting 신소재공학과 김 현 수

2 Gauss Elimination with scaled partial pivoting
WRITE(*,*) " Number of Equations = " ; READ *, n ALLOCATE(matrix(n,n), b(n), x(n), s(n)) DO i = 1, n WRITE(*,*) " Components of matrix and vector", i, " : " READ(*,*) matrix(i, 1:n), b(i) END DO s(i) = ABS(matrix(i,1)) DO j= 2, n IF (ABS(matrix(i,j)) > s(i)) THEN s(i) = ABS(matrix(i,j)) END IF CALL GaussElimination(matrix, b, x, s, n) 자료 입력단계 Define scale factor si for each row 가우스 소거법 서브루틴 호출

3 Gauss Elimination with scaled partial pivoting
DO i = 1, n value = ABS(matrix(i,i)/s(i)) ; pivot = i DO j = i + 1, n IF (ABS(matrix(j,i)/s(j)) > value) THEN value = ABS(matrix(j,i)/s(j)) ; pivot = j END IF END DO IF (pivot /= i) THEN temp(i:n) = matrix(i, i:n) ; tempb = b(i) matrix(i, i:n) = matrix(pivot, i:n) ; b(i) = b(pivot) matrix(pivot, i:n) = temp(i:n) ; b(pivot) = tempb factor = -matrix(j,i) / matrix(i,i) matrix(j, i:n) = matrix(j, i:n) + factor * matrix(i, i:n) b(j) = b(j) + factor * b(i) x(n) = b(n) / matrix(n,n) DO j = n-1, 1, -1 x(j) = (b(j) - SUM(matrix(j, j+1:n) * x(j+1:n))) / matrix(j,j) 최대 대각항을 찾음 Pivot 계산 후 matrix 요소를 재구성 Gauss Elimination 적용 후방대입법 (backward substitution) 을 이용하여 근을 계산

4 Gauss Elimination with scaled partial pivoting
PRINT *, "Solution is : “ DO i = 1, n PRINT '(1X, "x(",I3,") = ", F12.8)', i, x(i) END DO DEALLOCATE(matrix, b, x) 결과 출력단계 ※ 전체 구성 자료 입력 Scale factor 정의 가우스 소거법 서브루틴 호출 결과 출력 Scaled partial pivoting Gauss Elimination Backward Substitution

5 Gauss Elimination with scaled partial pivoting
3.3330x x x3 = x x x3 = x x2 – x3 = Actual solution x1 = 1, x2 = 0.5, x3 = -1 문제설정 및 실제 답과 프로그램 실행결과 프로그램 실행결과와 Actual solution이 일치함

6 Gauss Elimination with scaled partial pivoting
1.19x x x3 + x4 = 1.12 14.2x x x3 - x4 = 3.44 100x2 – 99.9x3 + x4 = 2.15 15.3x x2 – 13.1x3 - x4 = 4.16 문제설정 및 실제 답과 프로그램 실행결과 Actual solution x1 = , x2 = , x3 = , x4 = 프로그램 실행결과와 Actual solution이 일치함


Download ppt "Gauss Elimination with scaled partial pivoting"

Similar presentations


Ads by Google