This would greatly improve your code (and make it way faster) and make it way easier to read. I notice that you import numpy, but you don't use the operations for numpy arrays.If you don't use a variable in a list comprehension, then it is customary to use an _.Python only uses to place two lines of code on the same physical line. Python doesn't need to end a line, python knows when lines end.There are many things to address in your code: Print("Here's the solution for your matrix: ") Print("Lower Triangular\t\tUpper Triangular") # Sigma from j to i for each column k of L # Decomposing matrix into upper and lower matrices Shared Code Below: def lu_decomposition(matrix_in, b_in, n): I fixed the issue it was simply a bug in the code during LU decomposition. Is it an issue with a round-off or truncation error? Any advice or help would be appreciated. LU:Īs you can see the LU gives me a slightly different result.However, the results of the LU decomposition bothers me.įor example, if my matrix A and vector b are A = np.array(, I wrote a few functions that solve systems of linear equations following these three methods: Development Environment: Spyder4 (Python 3.7)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |