Fixed bug with incorrect LU decomposition (#2261)

* Fixed Bug #2257

* =

Co-authored-by: Svn-Sp <svn-sp@email>
Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
Sven 2020-08-01 22:11:39 +02:00 committed by GitHub
parent 473072bd4f
commit 1495382367
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -13,15 +13,15 @@ def LUDecompose(table):
if rows != columns:
return []
for i in range(columns):
for j in range(i - 1):
for j in range(i):
sum = 0
for k in range(j - 1):
for k in range(j):
sum += L[i][k] * U[k][j]
L[i][j] = (table[i][j] - sum) / U[j][j]
L[i][i] = 1
for j in range(i - 1, columns):
for j in range(i, columns):
sum1 = 0
for k in range(i - 1):
for k in range(i):
sum1 += L[i][k] * U[k][j]
U[i][j] = table[i][j] - sum1
return L, U

View File

@ -27,7 +27,7 @@ def newton(function: RealFunc, derivative: RealFunc, starting_int: int,) -> floa
...
ZeroDivisionError: Could not find root
"""
prev_guess float(starting_int)
prev_guess = float(starting_int)
while True:
try:
next_guess = prev_guess - function(prev_guess) / derivative(prev_guess)