Solved Task 3

This commit is contained in:
schrom01 2022-10-07 11:07:47 +02:00
parent 14704d5cc6
commit ee463720d9
1 changed files with 7 additions and 6 deletions

View File

@ -17,12 +17,12 @@ y_new = np.array([])
for i in range(50): for i in range(50):
sum_s = sn * n sum_s = sn * n
sum_s_new = sn_new * n sum_s_new = sn_new * n
pi = sum_s / 2 pi2 = sum_s
pi_new = sum_s_new / 2 pi2_new = sum_s_new
print("n: ", n, " sn: ", sn_new, " pi: ", pi) print("n: ", n, " sn: ", sn_new, " pi: ", pi2)
x = np.append(x, n) x = np.append(x, n)
y = np.append(y, pi) y = np.append(y, pi2)
y_new = np.append(y_new, pi_new) y_new = np.append(y_new, pi2_new)
n = n * 2 n = n * 2
sn = s2n(sn) sn = s2n(sn)
@ -34,8 +34,9 @@ plt.plot(x, y)
plt.plot(x, y_new) plt.plot(x, y_new)
plt.xscale('log', base=2) plt.xscale('log', base=2)
plt.xlim((2**3, 2**31)) plt.xlim((2**3, 2**31))
plt.ylim((3.125, 3.15)) plt.ylim((6.25, 6.3))
plt.legend(["pi", "pi_new"]) plt.legend(["pi", "pi_new"])
plt.title("Aufgabe 3")
plt.show() plt.show()
# mit der ersten Formel stimmt der berechnete Wert ab n = 50331648 nicht mehr. # mit der ersten Formel stimmt der berechnete Wert ab n = 50331648 nicht mehr.