33 lines
542 B
Python
33 lines
542 B
Python
# %%
|
|
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")
|