Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sffgg
! Creating a program to solve a numerical set by using Gauss elimination method(backward substitution) Real a(10,10),b(10),x(10),pivot,sum Integer i,j,k,n,p WRITE(*,*)'Insert here the dimension of the matrix' Read(*,*)n Write(*,*)'Insert here the coefficients of the given equations in matrix form,also insert the values row wise' Do i=1,n Read(*,*)(a(i,j),j=1,n),b(i) !read the matrix End do Write(*,*)'So, the matrix form by the given coefficients of those equations is as follows' Do i=1,n ! Write the matrix WRITE(*,*) (a(i,j),j=1,n) End do Write(*,*)'hence the B vector will be is' Do i=1,n Write(*,*)b(i) End do Do i=1,n !loop begins for gauss elimination (backward elimination) max=abs(a(i,i)) !pivoting start right here d=i Do j=i+1,n If(abs(a(j,i)).gt.max)then max=abs(a(j,i)) p=j Do k=1,n ! interchanging rows temp1=a(p,k) a(p,k)=a(d,k) a(d,k)=temp1 End do temp2=b(p) b(p)=b(d) b(d)=temp2 pivot=a(p,d)/a(d,d) Do k=1,n a(p,k)=a(p,k)-pivot*a(d,k) End do b(p)=b(p)-pivot*b(d) Else pivot=a(j,d)/a(d,d) do k=1,n a(j,k)=a(j,k)-pivot*a(d,k) End do b(j)=b(j)-pivot*b(d) End if End do End do Write(*,*)'so, the triangular matrix after gauss elimination will be :' Do i=1,n Write(*,*)(a(i,j),j=1,n) End do Write(*,*)'therefore, the corresponding vector B is:' Do i=1,n Write(*,*)b(i) End do Do i=n,1,-1 !back substitution sum=0.0 Do j=i+1,n sum=sum+a(i,j)*x(j) End do x(i)=(b(i)-sum)/a(i,i) End do Write(*,*)'SO, THE SOLUTIONS OF THE GIVEN LINEAR EQUATIONS ARE :' Do i=1,n WRITE(*,10)i,x(i) End do 10 format('X(',I3,')=',f10.5) Stop End
run
|
edit
|
history
|
help
0
Adams-Bashforth Method for four step
DO CONTINUE
Question1(b)
A_03 practice 2(ii)
Comparison of three numbers
A_02 QUESTIONS NUMBER 3
y
A_02 THE GUASS SEIDEL METHOD
Example 45 175 page
Ashish.txt