There are different algorithms for partial pivoting. One common way is to search the column (the j variable) for the element with the largest absolute value and do a swap. It is hard to write the whole algorithm in detail in a comment. Dorfman and Daoutidis have a nice explanation (with code) in Section 2.6 of "Numerical Methods with Chemical Engineering Applications" (www.amazon.com/Numerical-Chemical-Engineering-Applications-Cambridge/dp/1107135117).
Hi Roberta, the link to the Python file above is still good. I think you might mean that I didn't give the key, just the start. I did that so the students in my class would practice it for themselves! If you are learning to code GE for the first time, it is probably a good idea for you to do the same. That said, you can go to 12:24 to see the whole code. Also, you can check out: www.et.byu.edu/~treedoug/_pages/teaching/ChEn263/Lectures/Lec11.html for some more resources, including some more images of codes of forward elimination and back substitution.
Thank you sir
You're welcome
thank you very much sir
You're welcome!
Hello,
Great code. How would you implement partial pivoting on this code. I am trying but stuck
There are different algorithms for partial pivoting. One common way is to search the column (the j variable) for the element with the largest absolute value and do a swap. It is hard to write the whole algorithm in detail in a comment. Dorfman and Daoutidis have a nice explanation (with code) in Section 2.6 of "Numerical Methods with Chemical Engineering Applications" (www.amazon.com/Numerical-Chemical-Engineering-Applications-Cambridge/dp/1107135117).
In the first for loop, looping over k, you just have to find the biggest element in the col k and swap this row with the current row k
for gaus elimination your index in the 3'rd for loop has to be j in range(k, n), not (k,n-1)
the Python file used in the video isn't up to date!
Hi Roberta, the link to the Python file above is still good.
I think you might mean that I didn't give the key, just the start. I did that so the students in my class would practice it for themselves! If you are learning to code GE for the first time, it is probably a good idea for you to do the same.
That said, you can go to 12:24 to see the whole code. Also, you can check out: www.et.byu.edu/~treedoug/_pages/teaching/ChEn263/Lectures/Lec11.html for some more resources, including some more images of codes of forward elimination and back substitution.