28 lines
759 B
Python
28 lines
759 B
Python
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
#Aufgabe 2a
|
|
xmin = 1.99
|
|
xmax = 2.01
|
|
x_number_of_points = 500
|
|
xsteps = (xmax - xmin) / x_number_of_points
|
|
def f(x):
|
|
return x ** 7 - 14 * x ** 6 + 84 * x ** 5 - 280 * x ** 4 + 560 * x ** 3 - 672 * x ** 2 + 448 * x - 128
|
|
def g(x):
|
|
return (x - 2) ** 7
|
|
x = np.arange(xmin, xmax + xsteps, xsteps)
|
|
yf = np.array([])
|
|
yg = np.array([])
|
|
for x_value in x:
|
|
yf = np.append(yf, f(x_value))
|
|
yg = np.append(yg, g(x_value))
|
|
plt.plot(x, yf)
|
|
plt.plot(x, yg)
|
|
plt.show()
|
|
print("min f: ", min(yf), "max f: ", max(yf))
|
|
print("min g: ", min(yg), "max g: ", max(yg))
|
|
|
|
#Die Werte sind sehr klein (von e-14 bis e-12)
|
|
# sodass Rundungsfehler entstehen wenn die Werte als Fliesskommazahlen
|
|
# zwischengespeichert werden.
|