From 156ccd783bb8a10539b3b5300ea9f6398ddaca71 Mon Sep 17 00:00:00 2001 From: zimmersandro Date: Sun, 15 Mar 2026 12:22:31 +0100 Subject: [PATCH] syle: run black formatter and changed comment description --- src/lineare_algebra/task3.py | 42 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/lineare_algebra/task3.py b/src/lineare_algebra/task3.py index cae43af..e413f69 100644 --- a/src/lineare_algebra/task3.py +++ b/src/lineare_algebra/task3.py @@ -1,12 +1,12 @@ -#%% +# %% import numpy as np import sympy as sp from IPython.display import display, Math -#%% +# %% # Parameter -A = np.array([[1,3,-1],[4,-2,8]]) -B = np.array([[-3,9,3],[-6,6,3]]) +A = np.array([[1, 3, -1], [4, -2, 8]]) +B = np.array([[-3, 9, 3], [-6, 6, 3]]) # Layout print(60 * "-") @@ -14,20 +14,20 @@ print("Aufgabe 3. Matrizen berechnen (Numpy)") print(__file__) print(60 * "-") -#Berechnung -C=A+B -D=-2*A -E=(1/3)*B -F=2*B-A +# Berechnung +C = A + B +D = -2 * A +E = (1 / 3) * B +F = 2 * B - A -#Ausgabe +# Ausgabe print(f"C = {C}") print(f"D = {D}") print(f"E = {E}") print(f"F = {F}") print(60 * "-") -#%% +# %% # Parameters A = sp.Matrix([[1, 3, -1], [4, -2, 8]]) B = sp.Matrix([[-3, 9, 3], [-6, 6, 3]]) @@ -41,10 +41,10 @@ print("-" * 60) # Berechnung C = A + B D = -2 * A -E = sp.Rational(1, 3) * B # ← keeps fractions exact, e.g. 1 not 0.333... +E = sp.Rational(1, 3) * B # ← keeps fractions exact, e.g. 1 not 0.333... F = 2 * B - A -# Ausgabe – symbolic, paper-style +# Ausgabe, symbolisch for name, matrix in [("C", C), ("D", D), ("E", E), ("F", F)]: display(Math(rf"{name} = {sp.latex(matrix)}")) @@ -52,10 +52,10 @@ print("-" * 60) # %% # Parameters -A = sp.Matrix([[4,-3,2],[6,2,5],[-1,-2,3]]) -B = sp.Matrix([[3,4],[1,2],[5,6]]) -u = sp.Matrix([0,2,-4]) -v = sp.Matrix([1,3,-3]) +A = sp.Matrix([[4, -3, 2], [6, 2, 5], [-1, -2, 3]]) +B = sp.Matrix([[3, 4], [1, 2], [5, 6]]) +u = sp.Matrix([0, 2, -4]) +v = sp.Matrix([1, 3, -3]) # Layout print("-" * 60) @@ -68,13 +68,13 @@ berechnungen = [ ("a", lambda: A * B), ("b", lambda: B * A), ("c", lambda: A * u), - ("d", lambda: A ** 2), + ("d", lambda: A**2), ("e", lambda: B * B), ("f", lambda: v.T * u), ("g", lambda: v * u), - ("h", lambda:u * v.T), + ("h", lambda: u * v.T), ("i", lambda: B.T * v), - ("j", lambda: v.T * B) + ("j", lambda: v.T * B), ] for name, berechnung in berechnungen: @@ -82,4 +82,4 @@ for name, berechnung in berechnungen: result = berechnung() display(Math(rf"{name} = {sp.latex(result)}")) except Exception as e: - display(Math(rf"{name} = \text{{Fehler: }} \text{{{e}}}")) \ No newline at end of file + display(Math(rf"{name} = \text{{Fehler: }} \text{{{e}}}"))