From a973b8170707342402f7833fe1a4abb74be5a99a Mon Sep 17 00:00:00 2001 From: zimmersandro Date: Mon, 26 Oct 2026 13:53:24 +0100 Subject: [PATCH] Serie 5 Aufgabe 3. Funktionen Plotten. Script plottet funktionen mit matplotlib --- reelle_funktionen/serie_5_3.py | 57 ++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 reelle_funktionen/serie_5_3.py diff --git a/reelle_funktionen/serie_5_3.py b/reelle_funktionen/serie_5_3.py new file mode 100644 index 0000000..de3fbd3 --- /dev/null +++ b/reelle_funktionen/serie_5_3.py @@ -0,0 +1,57 @@ +#%% +import numpy as np +import matplotlib.pyplot as plt + +fig = 0 +lw = 3 + +functions = [ + { + "x_0": 0., + "x_E": 2., + "N": 2, + "f": lambda x: 0.4 * x + 1, + }, + { + "x_0": -2., + "x_E": 2., + "N": 129, + "f": lambda x: x ** 2, + }, + { + "x_0": -6., + "x_E": 2., + "N": 129, + "f": lambda x: 2 ** x, + }, + { + "x_0": 0.01, + "x_E": 10., + "N": 129, + "f": lambda x: np.log(x)/np.log(10), + }, + { + "x_0": -1, + "x_E": 4, + "N": 129, + "f": lambda x: 3 / (x + 2), + }, + { + "x_0": 0, + "x_E": 4 * np.pi, + "N": 257, + "f": lambda x: 2 * np.sin(x), + }, +] + +for function in functions: + x_data = np.linspace(function["x_0"], function["x_E"], function["N"]) + y_data = function["f"](x_data) + + fh = plt.figure(fig) + fig += 1 + plt.plot(x_data, y_data, linewidth=lw) + plt.xlabel(r"$x$") + plt.ylabel(r"$y$") + plt.grid(visible=True) + plt.axis("image") \ No newline at end of file