2022-09-24 19:18:32 +02:00
|
|
|
import numpy as np
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
2022-09-24 19:55:14 +02:00
|
|
|
xmin, xmax, xsteps = -10, 10, 0.1
|
|
|
|
plotLegend = []
|
2022-09-24 19:18:32 +02:00
|
|
|
|
2022-09-24 19:55:14 +02:00
|
|
|
def showPlot():
|
2022-09-24 19:18:32 +02:00
|
|
|
plt.xlim(-11, 11)
|
2022-09-24 19:22:58 +02:00
|
|
|
plt.xticks(np.arange(xmin, xmax + xsteps, 1.0))
|
2022-09-24 19:55:14 +02:00
|
|
|
plt.xlabel("x")
|
2022-09-24 19:18:32 +02:00
|
|
|
plt.ylim(-1300, 1300)
|
2022-09-24 19:55:14 +02:00
|
|
|
plt.ylabel("y")
|
2022-09-24 19:18:32 +02:00
|
|
|
plt.grid(markevery=1)
|
2022-09-24 19:55:14 +02:00
|
|
|
plt.legend(plotLegend)
|
|
|
|
plt.title("Aufgabe 1")
|
2022-09-24 19:18:32 +02:00
|
|
|
plt.show()
|
|
|
|
|
2022-09-24 19:55:14 +02:00
|
|
|
def function_f(x):
|
|
|
|
return x ** 5 - 5 * x ** 4 - 30 * x ** 3 + 110 * x ** 2 + 29 * x - 105
|
|
|
|
|
|
|
|
def derivative_f(x):
|
|
|
|
return 5 * x ** 4 - 20 * x ** 3 - 90 * x ** 2 + 220 * x + 29
|
|
|
|
|
|
|
|
def integral_f(x):
|
|
|
|
c = 0
|
|
|
|
return (1/6) * x ** 6 - x ** 5 - (30/4) * x ** 4 + (110/3) * x ** 3 + (29/2) * x ** 2 - 105 * x + c
|
|
|
|
|
|
|
|
def plot_function_f():
|
|
|
|
x = np.arange(xmin, xmax + xsteps, xsteps)
|
|
|
|
f = np.array(function_f(x))
|
|
|
|
plt.plot(x, f)
|
|
|
|
plotLegend.append('f(x)')
|
|
|
|
|
|
|
|
def plot_derivative_f():
|
|
|
|
x = np.arange(xmin, xmax + xsteps, xsteps)
|
|
|
|
f = np.array(derivative_f(x))
|
|
|
|
plt.plot(x, f)
|
|
|
|
plotLegend.append('f\'(x)')
|
|
|
|
|
|
|
|
def plot_integral_f():
|
|
|
|
x = np.arange(xmin, xmax + xsteps, xsteps)
|
|
|
|
f = np.array(integral_f(x))
|
|
|
|
plt.plot(x, f)
|
|
|
|
plotLegend.append('F(x)')
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
plot_function_f()
|
|
|
|
plot_derivative_f()
|
|
|
|
plot_integral_f()
|
|
|
|
showPlot()
|