Compare commits
2 Commits
bd928b6a3a
...
5991cc7a13
Author | SHA1 | Date |
---|---|---|
schrom01 | 5991cc7a13 | |
schrom01 | 9b6be2f99d |
|
@ -32,22 +32,31 @@ print("min f2: ", min(yf2), "max f2: ", max(yf2))
|
||||||
xmin = -10 ** -14
|
xmin = -10 ** -14
|
||||||
xmax = 10 ** -14
|
xmax = 10 ** -14
|
||||||
xsteps = 10 ** -17
|
xsteps = 10 ** -17
|
||||||
def g(x):
|
def g1(x):
|
||||||
return x / (np.sin(1 + x) - np.sin(1))
|
return x / (np.sin(1 + x) - np.sin(1))
|
||||||
x2 = np.arange(xmin, xmax + xsteps, xsteps)
|
x2 = np.arange(xmin, xmax + xsteps, xsteps)
|
||||||
yg = np.array([])
|
yg1 = np.array([])
|
||||||
for x_value in x2:
|
for x_value in x2:
|
||||||
yg = np.append(yg, g(x_value))
|
yg1 = np.append(yg1, g1(x_value))
|
||||||
plt.plot(x2, yg)
|
plt.plot(x2, yg1)
|
||||||
plt.legend(["g(x)"])
|
print("min g1: ", min(yg1), "max g1: ", max(yg1))
|
||||||
plt.figure()
|
|
||||||
print("min g: ", min(yg), "max g: ", max(yg))
|
|
||||||
|
|
||||||
# Die Berechnung des Grenzwertes für x --> 0 g(x) ist nicht stabil.
|
# Die Berechnung des Grenzwertes für x --> 0 g(x) ist nicht stabil.
|
||||||
# Der Grenzwert scheint unendlich gross / klein zu sein.
|
# Der Grenzwert scheint unendlich gross / klein zu sein.
|
||||||
|
|
||||||
# Aufgabe 2c
|
# 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()
|
plt.show()
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
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)
|
||||||
|
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()
|
||||||
|
|
||||||
|
# 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