HM1_Aufgabenserie2/Schenk_Brandenberger_S2_Auf...

21 lines
517 B
Python
Raw Normal View History

2022-09-30 13:45:59 +02:00
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()