Compare commits
No commits in common. "953479550468d2e45f433df9238cba0ac43501af" and "e1f9d06b359d79c4d75a1ad7a1fcec29cb138985" have entirely different histories.
9534795504
...
e1f9d06b35
|
@ -18,17 +18,21 @@ def f2(x):
|
|||
|
||||
x1 = np.arange(xmin, xmax + xsteps, xsteps)
|
||||
|
||||
yf1 = [f1(x_value) for x_value in x1]
|
||||
yf2 = [f2(x_value) for x_value in x1]
|
||||
|
||||
#todo yf1 = [f1(x_value) for x_value in x1]
|
||||
#todo yf2 = [f2(x_value) for x_value in x1]
|
||||
yf1 = np.array([])
|
||||
yf2 = np.array([])
|
||||
for x_value in x1:
|
||||
yf1 = np.append(yf1, f1(x_value))
|
||||
yf2 = np.append(yf2, f2(x_value))
|
||||
plt.plot(x1, yf1, label='f1(x)')
|
||||
plt.plot(x1, yf2, label='f2(x)')
|
||||
plt.legend()
|
||||
plt.title("Aufgabe 2a")
|
||||
plt.figure()
|
||||
|
||||
print(f'min f1: {min(yf1)} max f1: {max(yf1)}')
|
||||
print(f'min f2: {min(yf2)} max f2: {max(yf2)}')
|
||||
print("min f1: ", min(yf1), "max f1: ", max(yf1))
|
||||
print("min f2: ", min(yf2), "max f2: ", max(yf2))
|
||||
|
||||
# Die Werte sind sehr klein (von -e-14 bis e-14)
|
||||
# sodass Rundungsfehler entstehen wenn die Werte als Fliesskommazahlen
|
||||
|
@ -49,9 +53,13 @@ def g1(x):
|
|||
|
||||
|
||||
x2 = np.arange(xmin, xmax + xsteps, xsteps)
|
||||
yg1 = [g1(x_value) for x_value in x2]
|
||||
# todo yg1 = [g1(x_value) for x_value in x2] ?
|
||||
yg1 = np.array([])
|
||||
for x_value in x2:
|
||||
yg1 = np.append(yg1, g1(x_value))
|
||||
plt.plot(x2, yg1, label='g1(x)')
|
||||
print(f'min g1: {min(yg1)} max g1: {max(yg1)}')
|
||||
#todo print(f'min g1: {min(yg1)} max g1: {max(yg1)}')
|
||||
print("min g1: ", min(yg1), "max g1: ", max(yg1))
|
||||
|
||||
|
||||
# Die Berechnung des Grenzwertes für x --> 0 g(x) ist nicht stabil.
|
||||
|
@ -62,12 +70,14 @@ print(f'min g1: {min(yg1)} max g1: {max(yg1)}')
|
|||
def g2(x):
|
||||
return x / (2 * np.cos((1 + x + 1) / 2) * np.sin((x) / 2))
|
||||
|
||||
#todo yg2 = [g2(x_value) for x_value in x2]
|
||||
yg2 = np.array([])
|
||||
|
||||
yg2 = [g2(x_value) for x_value in x2]
|
||||
|
||||
for x_value in x2:
|
||||
yg2 = np.append(yg2, g2(x_value))
|
||||
plt.plot(x2, yg2, label='g2(x)')
|
||||
|
||||
print(f'min g2: {min(yg2)} max g2: {max(yg2)}')
|
||||
#todo print(f'min g2: {min(yg2)} max g2: {max(yg2)}')
|
||||
print("min g2: ", min(yg2), "max g2: ", max(yg2))
|
||||
plt.legend()
|
||||
plt.title("Aufgabe 2bc")
|
||||
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
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 = 1 # Radius
|
||||
n = 6 # Anzahl Ecken
|
||||
r = 1 #Radius
|
||||
n = 6 #Anzahl Ecken
|
||||
sn = r
|
||||
sn_new = r
|
||||
x = np.array([])
|
||||
|
@ -31,16 +28,17 @@ for i in range(50):
|
|||
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((6.25, 6.3))
|
||||
plt.xlim((2**3, 2**31))
|
||||
plt.legend(["2*pi", "2*pi_new"])
|
||||
|
||||
plt.ylim((6.25, 6.3))
|
||||
plt.title("Aufgabe 3")
|
||||
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.
|
||||
# mit der zweiten Formel tritt der Fehler nicht auf.
|
Loading…
Reference in New Issue