Serie 5 Aufgabe 3. Funktionen Plotten. Script plottet funktionen mit matplotlib
This commit is contained in:
parent
799b18f586
commit
a973b81707
57
reelle_funktionen/serie_5_3.py
Normal file
57
reelle_funktionen/serie_5_3.py
Normal file
@ -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")
|
||||
Loading…
x
Reference in New Issue
Block a user