HM1_Aufgabenserie2/Schenk_Brandenberger_S2_Auf...

39 lines
799 B
Python

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()