From 4e316721893cb4fe992740a4f103bed9773a6f81 Mon Sep 17 00:00:00 2001 From: zimmersandro Date: Fri, 20 Mar 2026 15:17:32 +0100 Subject: [PATCH] feat: Plot Graphs --- .../reelwertige_nichtkonvexe_optimierung.py | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/optimierung/reelwertige_nichtkonvexe_optimierung.py b/src/optimierung/reelwertige_nichtkonvexe_optimierung.py index 26f42a3..364bbe0 100644 --- a/src/optimierung/reelwertige_nichtkonvexe_optimierung.py +++ b/src/optimierung/reelwertige_nichtkonvexe_optimierung.py @@ -1 +1,32 @@ -#%% \ No newline at end of file +# %% +import numpy as np +import matplotlib.pyplot as plt + +# Parameter +N = 200 + +# Funktionen +f_a = lambda x: -(1 / 3) * x**3 + (5 / 2) * x**2 - 4 * x + 1 +f_b = lambda x: np.abs(x**2 - 4 * x + 3) + +# Daten +x_a_data = np.linspace(0, 2, N) +x_b_data = np.linspace(0, 4, N) + +f_a_data = f_a(x_a_data) +f_b_data = f_b(x_b_data) + +# Plot +plt.figure(1) +plt.plot(x_a_data, f_a_data) +plt.xlabel("x") +plt.ylabel("y") +plt.grid("on") +plt.axis("image") + +plt.figure(2) +plt.plot(x_b_data, f_b_data) +plt.xlabel("x") +plt.ylabel("y") +plt.grid("on") +plt.axis("image")