не могу сгладить график, подскажите пожалуйста
import numpy as np
import matplotlib.pyplot as plt
def fun_1(x):
if x > -4 and x <= -2:
return 2
if x > -2 and x <= 0:
return abs(x)
if x > 0 and x <= 2:
return x
if x > 2 and x <= 4:
return 2
def fun(t):
tmp = 0
for k in range(1, 4):
tmp += (1 / (k ** 2)) * (np.cos(((np.pi * k) / 2)) - 1) * (np.cos((np.pi * k * t) / 4))
return ((8 / (np.pi ** 2)) * tmp) + 3 / 2
z = []
y = []
z1 = []
y1 = []
for t in range(-4, 5):
z.append(t)
y.append(fun(t))
for x in range(-6, 5):
z1.append(x)
y1.append(fun_1(x))
z_sm = np.array(z)
y_sm = np.array(y)
plt.plot(z_sm, y_sm)
plt.plot(z1, y1)
plt.grid()
plt.show()