Solved Task 2b
This commit is contained in:
parent
9b6be2f99d
commit
5991cc7a13
|
@ -19,7 +19,7 @@ for i in range(50):
|
||||||
sum_s_new = sn_new * n
|
sum_s_new = sn_new * n
|
||||||
pi = sum_s / 2
|
pi = sum_s / 2
|
||||||
pi_new = sum_s_new / 2
|
pi_new = sum_s_new / 2
|
||||||
print("n: ", n, " sn: ", sn_new, " pi: ", pi_new)
|
print("n: ", n, " sn: ", sn_new, " pi: ", pi)
|
||||||
x = np.append(x, n)
|
x = np.append(x, n)
|
||||||
y = np.append(y, pi)
|
y = np.append(y, pi)
|
||||||
y_new = np.append(y_new, pi_new)
|
y_new = np.append(y_new, pi_new)
|
||||||
|
@ -36,4 +36,9 @@ 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((3.125, 3.15))
|
||||||
plt.legend(["pi", "pi_new"])
|
plt.legend(["pi", "pi_new"])
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
# mit der ersten Formel stimmt der berechnete Wert ab n = 50331648 nicht mehr.
|
||||||
|
# mit n = 805306368 erhält man für pi 6, danach immer 0.
|
||||||
|
|
||||||
|
# mit der zweiten Formel tritt der Fehler nicht auf.
|
Loading…
Reference in New Issue