27 lines
472 B
Python
27 lines
472 B
Python
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
def u(x, p):
|
|
if p == 0:
|
|
return x
|
|
else:
|
|
return (np.exp(p*x)-1)/(np.exp(p)-1)
|
|
|
|
|
|
x = np.linspace(0, 1, 200)
|
|
|
|
p_values = [-10, -2, 0, 2, 10]
|
|
colors = ['purple', 'blue', 'black', 'orange', 'red']
|
|
|
|
|
|
|
|
plt.figure(figsize=(7,5))
|
|
for p, c in zip(p_values, colors):
|
|
plt.plot(x, u(x, p), label=f"p = {p}", color=c, linewidth=2)
|
|
|
|
|
|
plt.xlabel("x")
|
|
plt.ylabel("u(x)")
|
|
plt.legend()
|
|
plt.grid(True)
|
|
plt.show()
|