gaussian elimination

1105 days ago by ncr006

var('a11 a12 a13 a21 a22 a23 a31 a32 a33 b1 b2 b3') A = matrix(SR, 2, 2, [a11, a12, a21, a22]) b = matrix(SR,2,1,[b1, b2]) show(A); show(b) 
       

                                
                            

                                
A.add_multiple_of_row(1,0,-a21/a11) b.add_multiple_of_row(1,0,-a21/a11) show(A); show(b) 
       

                                
                            

                                
A = matrix(SR, 3, 3, [a11, a12, a13, a21, a22, a23, a31, a32, a33]) b = matrix(SR, 3, 1, [b1, b2, b3]) show(A); show(b) 
       

                                
                            

                                
# a11 is the pivot # the multiplier is the first entry of the the ith column divided by the pivot A.add_multiple_of_row(1,0,-a21/a11) #k=0, i=1, the j just means do the whole ith row b.add_multiple_of_row(1,0,-a21/a11) show(A); show(b) 
       

                                
                            

                                
A.add_multiple_of_row(2,0,-a31/a11) #k=0, i=2, the j just means do the whole ith row b.add_multiple_of_row(2,0,-a31/a11) show(A); show(b) 
       

                                
                            

                                
a22prime = A[1,1] # define the new pivot a32prime = A[2,1] # the multiplier is the first entry of the ith column divided by the pivot A.add_multiple_of_row(2,1,-a32prime/a22prime) b.add_multiple_of_row(2,1,-a32prime/a22prime) show(A); show(b)