From 1495382367a2a25ffd362b71610251afe4fab668 Mon Sep 17 00:00:00 2001 From: Sven <69042800+Svn-Sp@users.noreply.github.com> Date: Sat, 1 Aug 2020 22:11:39 +0200 Subject: [PATCH] Fixed bug with incorrect LU decomposition (#2261) * Fixed Bug #2257 * = Co-authored-by: Svn-Sp Co-authored-by: Christian Clauss --- arithmetic_analysis/lu_decomposition.py | 8 ++++---- arithmetic_analysis/newton_method.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arithmetic_analysis/lu_decomposition.py b/arithmetic_analysis/lu_decomposition.py index 4372621d7..763ba60f3 100644 --- a/arithmetic_analysis/lu_decomposition.py +++ b/arithmetic_analysis/lu_decomposition.py @@ -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 diff --git a/arithmetic_analysis/newton_method.py b/arithmetic_analysis/newton_method.py index fd7ad45c2..542f994aa 100644 --- a/arithmetic_analysis/newton_method.py +++ b/arithmetic_analysis/newton_method.py @@ -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)