

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Lab notes for students in the hydrology program at new mexico tech, focusing on linear algebraic quantitative methods in hydrology. It includes instructions for writing codes to perform gaussian elimination and jacobi iterations to solve systems of linear algebraic equations. These methods are essential for understanding and solving real-world hydrological problems.
Typology: Study notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!
New Mexico Tech Hyd 510 Hydrology Program Lab Notes. 5 Linear Algebraic Quantitative Methods in Hydrology Equations and Solvers
1. Write a code to perform Gaussian Elimination Given a square (nxn) non-symmetric coefficient matrix A , and (nx1) load vector b , write a Gaussian Elimination code to solve the system of linear algebraic equations 1 Ax=b for unknown vector x. A suggested pseudo-code (generic algorithm outline) is:
Input n, an nxn matrix A , and an nx1 vector b
Forward Elimination for j= 1 to n- for i = j+1 to n mij = aij /ajj aij = 0; bi = bi – mij *bj
for k = j +1 to n aik = aik – mij * ajk
Backsubstitution for i= n downto 1 xi = bi for j = i+1 to n xi = xi – aij *xj xi = xi /aii
Output Solution vector x
2. Write a code to perform Jacobi iterations
Given a square ( n x n ) non-symmetric coefficient matrix A , and ( n x1) load vector b , write an code to solve the system of linear algebraic equations Ax=b for unknown ( n x1) vector x using Jacobi iteration.
1
≠=
n
jji
i ij j ii
k i
and for decent initial guesses, the method converges. We need a stopping criteria, to stop the process when the solution is “sufficiently close”. Let’s use a comparison of old and new values of x. If, for any i , the absolute value
(^1) Note the shift in the notation for the vector of unknowns, from z to x. It is traditional to use x for this purpose, as in the text, Chapter 20, so I’ve made the shift in this assignment.
New Mexico Tech Hyd 510 Hydrology Program Lab Notes. 5 Linear Algebraic Quantitative Methods in Hydrology Equations and Solvers
continue to iterate (there are many other possible criteria). We also need to specify the maximum number of iterations we will allow, in order to insure that the method doesn’t run forever. Call this number maxit.
A suggested pseudo-code is: Input Input n, A , b , x^0 , eps, maxit
Initialization,Check Matrix Condition (zeros on diagonal) for i= 1 to n if |aii | < eps, then print ‘algorithm fails because |a (^) ii | < eps’ and exit print b , x^0 , eps, maxit k=0; x =x^0 ;
Perform Iterations
k = k+ for i = 1 to n xoldi = xi for i = 1 to n sum = 0 for j = 1 to n
xi = (bi - sum)/aii
Check convergence for i = 1 to n
Backsubstitution (see Gaussian Elimination Example)
Output
Print k, x , and exit (inside k loop) Print ‘ Algorithm failed to converge’ if k exceeds maxit and exit