50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
xmin, xmax, xsteps = -10, 10, 0.1
|
|
plotLegend = []
|
|
|
|
def showPlot():
|
|
plt.xlim(-11, 11)
|
|
plt.xticks(np.arange(xmin, xmax + xsteps, 1.0))
|
|
plt.xlabel("x")
|
|
plt.ylim(-1300, 1300)
|
|
plt.ylabel("y")
|
|
plt.grid(markevery=1)
|
|
plt.legend(plotLegend)
|
|
plt.title("Aufgabe 1")
|
|
plt.show()
|
|
|
|
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() |