Hi Can any one help i want to make zone to inter thé number Matrix | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hi Can any one help i want to make zone to inter thé number Matrix

#gauss elimination import numpy as np n = int(input('Enter number of unknowns: ')) a=np.array([1,4,3,2],[3,6,1,0],[2,4,3,1],) b=np.array([5,4,2,3]) n=len(a) for k in range(0,n): pivot=a[k][k] for (pivot!=0): l[k][k]=1 for i in range (k+1,n): l[i][k]=(a[i][k])/pivot for j in range(k+1,n): a[i][j]=(a[i][j])-(l[i][k]*a[k][j])

21st Feb 2021, 6:47 PM
Rayeh Mohammed Riad
Rayeh Mohammed Riad - avatar
1 Answer
+ 1
looking over the code, i discovered you have misused the for loop. I think you meant to use a while loop. the for loop iterates over the elements of a sequence, while a while loop continues until a condition is false. i’m not sure what math is supposed to be going on here, so there might be other problems I don’t know about. as an extra tip, the range function returns a sequence from the starting point (you wrote k+1) up to but not including the end point (n in both cases), with a default increment of +1. so, to get the numbers from 1 to and including 10, you would do range(1, 11) or you could just do range(10) but then add 1 to the value, since range starts at 0 by default.
22nd Feb 2021, 11:19 PM
Wilbur Jaywright
Wilbur Jaywright - avatar