Using gaussian elimination and backwards substitution, solve for the x terms in the augmented matrix below: 2 4 -2 x1 3 -1 5 -2 1 1 1 2 3 ✓ [Choose ]

Algebra and Trigonometry (6th Edition)
6th Edition
ISBN:9780134463216
Author:Robert F. Blitzer
Publisher:Robert F. Blitzer
ChapterP: Prerequisites: Fundamental Concepts Of Algebra
Section: Chapter Questions
Problem 1MCCP: In Exercises 1-25, simplify the given expression or perform the indicated operation (and simplify,...
icon
Related questions
Question
100%

import numpy as np
np.set_printoptions(precision=7, suppress=True, linewidth=100)


def gauss_jordan(A, b):
    n = len(b)
    
    # Combine A and b into augmented matrix
    Ab = np.concatenate((A, b.reshape(n,1)), axis=1)
    
    # Perform elimination
    for i in range(n):
        # Find pivot row
        max_row = i
        for j in range(i+1, n):
            if abs(Ab[j,i]) > abs(Ab[max_row,i]):
                max_row = j
        
        # Swap rows to bring pivot element to diagonal
        Ab[[i,max_row], :] = Ab[[max_row,i], :] # operation 1 of row operations
        
        # Divide pivot row by pivot element
        pivot = Ab[i,i]
        Ab[i,:] = Ab[i,:] / pivot
        
        # Eliminate entries below pivot
        for j in range(i+1, n):
            factor = Ab[j,i]
            Ab[j,:] -= factor * Ab[i,:] # operation 2 of row operations
    
    # Perform back-substitution
    for i in range(n-1, -1, -1):
        for j in range(i-1, -1, -1):
            factor = Ab[j,i]
            Ab[j,:] -= factor * Ab[i,:]
    
    # Extract solution vector x
    x = Ab[:,n]
    
    return x

if __name__ == "__main__":
    A = np.array([[2,3,-1],
              [4,-2,1],
              [-2,1,2]])
    b = np.array([5,1,3])

    x = gauss_jordan(A, b)
    print(x)

Using gaussian elimination and backwards substitution, solve for the x terms in the augmented
matrix below:
2
4
- 2
x1
x2
x3
3
-2
2
1
-1 5
1
1
2
3
✓ [Choose ]
2.0
1.65
.952
1.1
.725
1.4
4 pts
Transcribed Image Text:Using gaussian elimination and backwards substitution, solve for the x terms in the augmented matrix below: 2 4 - 2 x1 x2 x3 3 -2 2 1 -1 5 1 1 2 3 ✓ [Choose ] 2.0 1.65 .952 1.1 .725 1.4 4 pts
Expert Solution
steps

Step by step

Solved in 3 steps with 30 images

Blurred answer
Recommended textbooks for you
Algebra and Trigonometry (6th Edition)
Algebra and Trigonometry (6th Edition)
Algebra
ISBN:
9780134463216
Author:
Robert F. Blitzer
Publisher:
PEARSON
Contemporary Abstract Algebra
Contemporary Abstract Algebra
Algebra
ISBN:
9781305657960
Author:
Joseph Gallian
Publisher:
Cengage Learning
Linear Algebra: A Modern Introduction
Linear Algebra: A Modern Introduction
Algebra
ISBN:
9781285463247
Author:
David Poole
Publisher:
Cengage Learning
Algebra And Trigonometry (11th Edition)
Algebra And Trigonometry (11th Edition)
Algebra
ISBN:
9780135163078
Author:
Michael Sullivan
Publisher:
PEARSON
Introduction to Linear Algebra, Fifth Edition
Introduction to Linear Algebra, Fifth Edition
Algebra
ISBN:
9780980232776
Author:
Gilbert Strang
Publisher:
Wellesley-Cambridge Press
College Algebra (Collegiate Math)
College Algebra (Collegiate Math)
Algebra
ISBN:
9780077836344
Author:
Julie Miller, Donna Gerken
Publisher:
McGraw-Hill Education