Coding the Gauss Elimination Algorithm in Python (ChEn 263 - Supplement to Lecture 11, Fixed!)

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ก.ย. 2024

ความคิดเห็น • 10

  • @ANINDYA-001
    @ANINDYA-001 2 ปีที่แล้ว +3

    Thank you sir

  • @subejba4148
    @subejba4148 2 ปีที่แล้ว +1

    thank you very much sir

  • @curiousperson7228
    @curiousperson7228 3 ปีที่แล้ว +1

    Hello,
    Great code. How would you implement partial pivoting on this code. I am trying but stuck

    • @TreeSoftMatter
      @TreeSoftMatter  3 ปีที่แล้ว +1

      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).

    • @chiefsteve6116
      @chiefsteve6116 ปีที่แล้ว

      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

  • @chiefsteve6116
    @chiefsteve6116 ปีที่แล้ว

    for gaus elimination your index in the 3'rd for loop has to be j in range(k, n), not (k,n-1)

  • @robertacarina
    @robertacarina 3 ปีที่แล้ว

    the Python file used in the video isn't up to date!

    • @TreeSoftMatter
      @TreeSoftMatter  3 ปีที่แล้ว +1

      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.