Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
problem_2
PROGRAM GAUSS_ELIMINATION IMPLICIT NONE REAL::mat(3,4),temp INTEGER::i,j,k mat(1,1) = 6 mat(1,2) = 5 mat(1,3) = 3 mat(1,4) = 14 mat(2,1) = 8 mat(2,2) = -3 mat(2,3) = 2 mat(2,4) = 11 mat(3,1) = 10 mat(3,2) = -7 mat(3,3) = -8 mat(3,4) = 21 call printMatrix(mat) call convertDiagonallyDominant(mat) call guass_seidal(mat) call jacobi(mat) End Program subroutine convertDiagonallyDominant(mat) Implicit none Real :: mat(3,4),temp integer::i,j do i=1,4 temp = mat(1,i) mat(1,i) = mat(3,i) mat(3,i) = temp end do do i=1,4 mat(2,i) = mat(2,i) - mat(3,i) end do do i=1,4 mat(3,i) = mat(3,i) - mat(1,i)+mat(2,i) end do write(*,*)'' write(*,*)'' write(*,*)'Converted Diagonally Dominant Matrix :' call printMatrix(mat) end subroutine subroutine guass_seidal(mat) implicit none real :: mat(3,4),x(3) integer:: i, j x(1) = 1.5 x(2) = 1.5 x(3) = -0.5 write(*,*) "" write(*,*) "" write(*,*) "" do i = 1,50 x(1) = (mat(1,4) + ( -1.0 * mat(1,2) * x(2)) + ( -1.0 * mat(1,3) * x(3)))/mat(1,1) x(2) = (mat(2,4) + ( -1.0 * mat(2,1) * x(1)) + ( -1.0 * mat(2,3) * x(3)))/mat(2,2) x(3) = (mat(3,4) + ( -1.0 * mat(3,1) * x(1)) + ( -1.0 * mat(3,2) * x(2)))/mat(3,3) write(*,*) x end do write(*,*) "using gauss seidal method roots are",x end subroutine subroutine jacobi(mat) implicit none real :: mat(3,4),x(3),x0(3) integer:: i, j x0(1) = 1.5 x0(2) = 1.5 x0(3) = -0.5 write(*,*) "" write(*,*) "" write(*,*) "" do i = 1,50 x(1) = (mat(1,4) + ( -1.0 * mat(1,2) * x0(2)) + ( -1.0 * mat(1,3) * x0(3)))/mat(1,1) x(2) = (mat(2,4) + ( -1.0 * mat(2,1) * x0(1)) + ( -1.0 * mat(2,3) * x0(3)))/mat(2,2) x(3) = (mat(3,4) + ( -1.0 * mat(3,1) * x0(1)) + ( -1.0 * mat(3,2) * x0(2)))/mat(3,3) write(*,*) x x0 = x end do write(*,*) "using jacobi method roots are",x end subroutine Subroutine printMatrix(mat) Implicit none Real,intent (in)::mat(3,4) integer::i,j write(*,*) "" do i=1,3 write(*,*) mat(i,1),mat(i,2),mat(i,3),mat(i,4) end do End Subroutine function norm(x) implicit none real::norm,x(3,1) integer::i norm=0 do i=1,3 norm=norm+x(i,1)**2 end do norm=sqrt(norm) end function
run
|
edit
|
history
|
help
0
Recursive tribonacci
euler-cromer
A_02 Newton's practice
Practice cheby
Jánošík 2018
Title
stochastic matrix
gghhhhh
Practice 2(I)
Question1(c)