Question: Why is my following code not showing the correct roots of the system of linear equations? The code must be done using naive gaussian elimination.

Why is my following code not showing the correct roots of the system of linear equations? The code must be done using naive gaussian elimination. The roots should be [0.5,8,-6]

Why is my following code not showing the correct roots of the

code:

import numpy as np from time import time

A = np.matrix('10 2 -1 ; -3 -6 2 ; 1 1 5') b = np.matrix('27 ; -61.5 ; -21.5') x2 = np.linalg.solve(A,b) epsilon = np.finfo(np.float64).eps

def My_GE_ForLoops(A,b): (n,m) = A.shape if n!= m: return 'A must be square' A = A.copy() b = b.copy() for k in range(0, n-1): if abs(A[k,k])

x1, x2, x3 = My_GE_ForLoops(A,b)

print(x1)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!