Compare commits

..

No commits in common. "cd88f40805c2dabb83a70d333534961132694b75" and "6c528077acf8ee9dbc9a034cf5c215805de3b8a7" have entirely different histories.

4 changed files with 3 additions and 70 deletions

View File

@ -31,7 +31,8 @@ def Schenk_Brandenberger_S6_Aufg2(A, b):
countRowSwitch += 1 countRowSwitch += 1
else: else:
A, b = calculateRow(A, b, row, column) A, b = calculateRow(A, b, row, column)
#print("\nObere Dreiecksmatrix A:\n", A, "\nb:\n", b)
print("\nObere Dreiecksmatrix A:\n", A, "\nb:\n", b)
# Rückwärtseinsetzen # Rückwärtseinsetzen
columnsToEdit = [] columnsToEdit = []
@ -40,7 +41,7 @@ def Schenk_Brandenberger_S6_Aufg2(A, b):
for column in columnsToEdit: for column in columnsToEdit:
A, b = calculateRow(A, b, row, column) A, b = calculateRow(A, b, row, column)
row -= 1 row -= 1
#print("\nA:\n", A, "\nb:\n", b) print("\nA:\n", A, "\nb:\n", b)
det = 1 det = 1
result = [] result = []

Binary file not shown.

View File

@ -1,16 +0,0 @@
import numpy as np
import scipy
if __name__ == '__main__':
# Aufgabe 2c
A = np.array([[0.8, 2.2, 3.6],
[2.0, 3.0, 4.0],
[1.2, 2.0, 5.8]])
b = np.array([[2.4],
[1.0],
[4.0]])
p, l, u = scipy.linalg.lu(A)
print("\np:\n", p, "\nl:\n", l, "\nu:\n", u)

View File

@ -1,52 +0,0 @@
from Schenk_Brandenberger_S7_Aufg1 import Schenk_Brandenberger_S6_Aufg2
import numpy as np
import matplotlib.pyplot as plt
if __name__ == '__main__':
# Aufgabe 3a
x_plt_label_offset = 1997
x = np.array([0, 2, 9, 13])
y = np.array([150, 104, 172, 152])
A = np.array([
[x[0]**3, x[0]**2, x[0]**1, x[0]**0],
[x[1]**3, x[1]**2, x[1]**1, x[1]**0],
[x[2]**3, x[2]**2, x[2]**1, x[2]**0],
[x[3]**3, x[3]**2, x[3]**1, x[3]**0]])
b = np.array([
[y[0]],
[y[1]],
[y[2]],
[y[3]]])
p1 = Schenk_Brandenberger_S6_Aufg2(A, b)[0]
x_plt1_min = np.min(x)
x_plt1_max = np.max(x)
x_plt1_steps = (float(x_plt1_max) - float(x_plt1_min)) / 100.0
x_plt = np.arange(x_plt1_min, x_plt1_max + x_plt1_steps, x_plt1_steps)
plt.plot(x_plt + x_plt_label_offset, np.polyval(p1, x_plt), label="Aufgabe 3a")
# Aufgabe 3b
print("Schätzwert Aufgabe 3b für das Jahr 2003:", np.polyval(p1, 2003 - x_plt_label_offset))
print("Schätzwert Aufgabe 3b für das Jahr 2004:", np.polyval(p1, 2004 - x_plt_label_offset))
print()
# Aufgabe 3c
p2 = np.polyfit(x, y, 3)
x_plt2_min = np.min(x)
x_plt2_max = np.max(x)
x_plt2_steps = (float(x_plt2_max) - float(x_plt2_min)) / 100.0
x_plt = np.arange(x_plt2_min, x_plt2_max + x_plt2_steps, x_plt2_steps)
plt.plot(x_plt + x_plt_label_offset, np.polyval(p2, x_plt), label="Aufgabe 3c")
print("Schätzwert Aufgabe 3c für das Jahr 2003:", np.polyval(p2, 2003 - x_plt_label_offset))
print("Schätzwert Aufgabe 3c für das Jahr 2004:", np.polyval(p2, 2004 - x_plt_label_offset))
# Plots anzeigen
plt.title("Aufgabe 3")
plt.grid()
plt.legend()
plt.show()