Compare commits
14
Commits
c0912447fc
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33d4cf66eb | ||
|
|
5eb8cb5797 | ||
|
|
51163cdf1c | ||
|
|
26b3523b4d | ||
|
|
ecd625aaff | ||
|
|
5912373856 | ||
|
|
d1e1daca18 | ||
|
|
bed9e0c562 | ||
|
|
e108ba6f08 | ||
|
|
dff6d7b7b4 | ||
|
|
1d49cdbaf6 | ||
|
|
7921fabe3b | ||
|
|
fe87b3f2c8 | ||
|
|
86e2dfe26a |
Binary file not shown.
@@ -0,0 +1,59 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import math
|
||||
|
||||
def f1(x):
|
||||
return 5/((2 * x ** 2 ) ** (1/3))
|
||||
|
||||
def f2(x):
|
||||
return 10 ** 5 * (2 * np.e) ** (-x/100)
|
||||
|
||||
def f3(x):
|
||||
x2 = 2 * x
|
||||
x10_2x = math.pow(10,x2)
|
||||
x5 = 5 * x
|
||||
x2_5x = math.pow(2, x5)
|
||||
x10_2x_x2_5x = x10_2x / x2_5x
|
||||
y = math.pow(x10_2x_x2_5x, 2)
|
||||
return y
|
||||
xstep = 1
|
||||
xstart = xstep
|
||||
xstop = 100
|
||||
x = np.arange(xstart, xstop + xstep, xstep)
|
||||
|
||||
# Aufgabe (i)
|
||||
y1 = [f1(x_value) for x_value in x]
|
||||
plt.plot(x, y1, label="f1(x)")
|
||||
# Beide Achsen logarithmisch
|
||||
plt.xscale('log', base = 2)
|
||||
plt.yscale('log', base = 2)
|
||||
# Steigung: -2/3
|
||||
# Y-Achsenabschnitt: 0
|
||||
plt.grid()
|
||||
plt.title("(i)")
|
||||
plt.figure()
|
||||
|
||||
|
||||
# Aufgabe (ii)
|
||||
y2 = [f2(x_value) for x_value in x]
|
||||
plt.plot(x, y2, label="f2(x)")
|
||||
# Y - Achse logarithmisch
|
||||
plt.yscale('log', base = np.e)
|
||||
# Steigung: -1/3
|
||||
# Y-Achsenabschnitt: 100000
|
||||
plt.grid()
|
||||
plt.title("(ii)")
|
||||
plt.figure()
|
||||
|
||||
|
||||
# Aufgabe (iii)
|
||||
y3 = [f3(x_value) for x_value in x]
|
||||
plt.plot(x, y3, label="f3(x)")
|
||||
# Y - Achse logarithmisch
|
||||
plt.yscale('log', base = 10)
|
||||
# Steigung: 1
|
||||
# Y-Achsenabschnitt: 100000
|
||||
plt.grid()
|
||||
plt.title("(iii)")
|
||||
|
||||
plt.show()
|
||||
@@ -0,0 +1,69 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import math
|
||||
|
||||
def h1(x):
|
||||
try:
|
||||
return math.sqrt(100 * math.pow(x, 2) - 200 * x + 99)
|
||||
except:
|
||||
return
|
||||
|
||||
def h2(x):
|
||||
return math.sqrt((10 * x - 9) * (10 * x - 11))
|
||||
|
||||
def h1_diff(x):
|
||||
try:
|
||||
return (100 * x - 100) / math.sqrt(100 * math.pow(x, 2) - 200 * x + 99)
|
||||
except:
|
||||
return
|
||||
|
||||
def h2_diff(x):
|
||||
return (100 * x - 100) / math.sqrt((10*x-11)*(10*x-9))
|
||||
|
||||
def kondnumb1(x):
|
||||
try:
|
||||
return (np.abs(h1_diff(x)) * np.abs(x)) / np.abs(h1(x))
|
||||
except:
|
||||
return
|
||||
|
||||
def kondnumb2(x):
|
||||
return (np.abs(h2_diff(x)) * np.abs(x)) / np.abs(h2(x))
|
||||
|
||||
|
||||
xStep = math.pow(10, -7)
|
||||
xStart = 1.1
|
||||
xStop = 1.31
|
||||
|
||||
x = np.arange(xStart, xStop + xStep, xStep)
|
||||
yh1 = [h1(x_val) for x_val in x]
|
||||
yh2 = [h2(x_val) for x_val in x]
|
||||
ykondnumb1 = [kondnumb1(x_val) for x_val in x]
|
||||
ykondnumb2 = [kondnumb2(x_val) for x_val in x]
|
||||
|
||||
# Aufgabe 4a)
|
||||
plt.plot(x, yh1, label='h1(x)')
|
||||
plt.plot(x, yh2, label='h2(x)')
|
||||
plt.title("h(x) für Aufgabe 4a")
|
||||
plt.legend()
|
||||
plt.figure()
|
||||
# Da die Operation nicht gut konditioniert ist, erhält man für den Ausdruck inder Wurzel
|
||||
# bei x = 1.1, -1.4e-14 => ein kleiner Rundungsfehler
|
||||
# Somit kann die Wurzel für diesen x Werte nicht berechnet werden.
|
||||
|
||||
|
||||
# Aufgabe 4b)
|
||||
plt.plot(x, ykondnumb1, label='Konditionszahl')
|
||||
plt.plot(x, ykondnumb2, label='Konditionszahl nach Umformung')
|
||||
plt.yscale('log', base=10)
|
||||
plt.title('Aufgabe 4b)')
|
||||
plt.legend()
|
||||
plt.figure()
|
||||
|
||||
# Aufgabe 4c)
|
||||
# Die umgeformte Algebraisch umgeformte Funktion h2 ist besser konditioniert.
|
||||
# Für den Audruck in der Wurzel wird genau 0.0 berechnet (bei x = 1.1).
|
||||
# Es entstehen keine Rundungsfehler mehr.
|
||||
|
||||
plt.show()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user