mathematik/analysis/aufgabenblatt_5_2.py

57 lines
916 B
Python

#%%
import numpy as np
import matplotlib.pyplot as plt
# Parameter
x = np.arange(0, 7, 0.1)
y = np.sin(x)
# Plot
plt.figure(1)
plt.plot(x, y, lw=3, label="sin(x)")
plt.xlabel("x")
plt.ylabel("y")
plt.legend("image")
plt.grid(visible=True)
plt.axis("image")
#%%
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
# Konfigurieren
mpl.rcParams["font.size"] = 20
mpl.rcParams["font.family"] = "serif"
# Parameter
x_0 = 0
x_E = 4
N = 201
lw = 3
fig = 1
# Funktionen
def f(x):
y = 3 / (1 + x)
return y
def g(x):
y = x / 2
return y
# Daten
x_data = np.linspace(x_0, x_E, N)
f_data = f(x_data)
g_data = g(x_data)
# Plot
plt.figure(fig)
plt.plot(x_data, f_data, linewidth = lw, label = r"$f = \frac{3} {1+x}$")
plt.plot(x_data, g_data, linewidth = lw, label = r"$g = \frac{x} {2}$")
plt.xlabel(r"$x$")
plt.ylabel(r"$y$")
plt.legend()
plt.grid(visible=True)
plt.axis("image")