Solved Task 2

This commit is contained in:
schrom01 2022-09-28 11:34:58 +02:00
parent 5874217e58
commit 468f47aa8a
1 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,41 @@
import numpy as np
import matplotlib.pyplot as plt
#Task Abbildung 1
x1 = np.arange(-5, 5.05, 0.05)
y1 = np.array([])
for x in x1:
y1 = np.append(y1, np.exp(x))
plt.xlim((-5, 5 + 0.05))
plt.title("Abbildung 1")
plt.plot(x1, y1)
plt.legend(["f(x) = e^x"])
plt.figure()
#Task Abbildung 2
x2 = np.arange(-10, 10.1, 0.1)
y2 = np.array([])
for x in x2:
y2 = np.append(y2, x**5 + 3*x**4 + 3*x**2 + x + 1)
plt.xlim((-10, 10 + 0.1))
plt.title("Abbildung 2")
plt.plot(x2, y2)
plt.legend(["p(x) = x^5 + 3x^4 + 3x^2 + x + 1"])
plt.figure()
#Task 3
x3 = np.arange(-2 * np.pi, 2 * np.pi + 0.01, 0.01)
y3_1 = np.array([])
y3_2 = np.array([])
for x in x3:
y3_1 = np.append(y3_1, 0.5 * np.sin(3 * x))
y3_2 = np.append(y3_2, 0.5 * np.cos(3 * x))
plt.xlim((-2 * np.pi, 2 * np.pi + 0.01))
plt.title("Abbildung 3")
plt.plot(x3, y3_1)
plt.plot(x3, y3_2)
plt.legend(["g(x) = 0.5 * sin(3x)", "h(x) = 0.5 * cos(3x)"])
plt.figure()
#Show Graphics
plt.show()