import numpy import matplotlib.pyplot as plt # matrix definition A = numpy.array([[1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3]]) B = numpy.array([[5, 4, 3, 2], [4, 3, 2, 5], [3, 2, 5, 4], [2, 5, 4, 3]]) b = numpy.array([[1], [2], [3], [4]]) def aufgabe_1(): # Teilaufgabe a print("Teilaufgabe a") print(A @ b) print(B @ b) print(A.transpose()) print(B.transpose()) print(A.transpose() @ A) print(B.transpose() @ B) # Teilaufgabe b print("Teilaufgabe b") print(A[3] @ B[1]) # Teilaufgabe c print("Teilaufgabe c") print(numpy.sum(A)) print(numpy.sum(B)) def aufgabe_2(): # Abbildung 1 plt.figure() plt.title("Abbildung 1") plt.xlabel("x") plt.ylabel("y") x = numpy.arange(-5, 5, 0.05) y = numpy.exp(x) plt.plot(x, y) # Abbildung 2 plt.figure() plt.title("Abbildung 2") plt.xlabel("x") plt.ylabel("y") x = numpy.arange(-10, 10, 0.1) y = (x ** 5 + 3 * x ** 4 + 3 * x ** 2 + x + 1) plt.plot(x, y) # Abbildung 3 plt.figure() plt.title("Abbildung 3") plt.xlabel("x") plt.ylabel("y") x = numpy.arange(-2 * numpy.pi, 2 * numpy.pi, 0.01) g = numpy.sin(3 * x) / 2 h = numpy.cos(3 * x) / 2 plt.plot(x, g) plt.plot(x, h) plt.show() if __name__ == "__main__": print("Aufgabe 1") aufgabe_1() print("Aufgabe 2") aufgabe_2()