diff --git a/Schenk_Brandenberger_S2_Aufg2.py b/Schenk_Brandenberger_S2_Aufg2.py index 6de5d9a..f349c35 100644 --- a/Schenk_Brandenberger_S2_Aufg2.py +++ b/Schenk_Brandenberger_S2_Aufg2.py @@ -32,22 +32,31 @@ print("min f2: ", min(yf2), "max f2: ", max(yf2)) xmin = -10 ** -14 xmax = 10 ** -14 xsteps = 10 ** -17 -def g(x): +def g1(x): return x / (np.sin(1 + x) - np.sin(1)) x2 = np.arange(xmin, xmax + xsteps, xsteps) -yg = np.array([]) +yg1 = np.array([]) for x_value in x2: - yg = np.append(yg, g(x_value)) -plt.plot(x2, yg) -plt.legend(["g(x)"]) -plt.figure() -print("min g: ", min(yg), "max g: ", max(yg)) + yg1 = np.append(yg1, g1(x_value)) +plt.plot(x2, yg1) +print("min g1: ", min(yg1), "max g1: ", max(yg1)) # Die Berechnung des Grenzwertes für x --> 0 g(x) ist nicht stabil. # Der Grenzwert scheint unendlich gross / klein zu sein. # Aufgabe 2c +# a = 1+x, b = 1 +def g2(x): + return x / (2 * np.cos((1 + x + 1) / 2) * np.sin((1 + x - 1) / 2)) +yg2 = np.array([]) +for x_value in x2: + yg2 = np.append(yg2, g2(x_value)) +plt.plot(x2, yg2) +print("min g2: ", min(yg2), "max g2: ", max(yg2)) +plt.legend(["g1(x)", "g2(x)"]) +# Der Grenzwert für x = 0 beträgt 1.85. Die Funktion ist nun stabil? +# plt.show() diff --git a/Schenk_Brandenberger_S2_Aufg3.py b/Schenk_Brandenberger_S2_Aufg3.py new file mode 100644 index 0000000..82297c4 --- /dev/null +++ b/Schenk_Brandenberger_S2_Aufg3.py @@ -0,0 +1,39 @@ +import numpy as np +import matplotlib.pyplot as plt + +def s2n(s1n): + return np.sqrt(2 - 2 * np.sqrt(1 - ((s1n ** 2) / 4))) + +def s2n_new(s1n): + return np.sqrt((s1n ** 2) / (2 * (1 + np.sqrt(1 - ((s1n ** 2) / 4))))) + +r = int(1) #Radius +n = int(6) #Anzahl Ecken +sn = r +sn_new = r +x = np.array([]) +y = np.array([]) +y_new = np.array([]) +for i in range(50): + sum_s = sn * n + sum_s_new = sn_new * n + pi = sum_s / 2 + pi_new = sum_s_new / 2 + print("n: ", n, " sn: ", sn_new, " pi: ", pi_new) + x = np.append(x, n) + y = np.append(y, pi) + y_new = np.append(y_new, pi_new) + + n = n * 2 + sn = s2n(sn) + sn_new = s2n_new(sn_new) + + + +plt.plot(x, y) +plt.plot(x, y_new) +plt.xscale('log', base=2) +plt.xlim((2**3, 2**31)) +plt.ylim((3.125, 3.15)) +plt.legend(["pi", "pi_new"]) +plt.show() \ No newline at end of file