import numpy as np
def f(x: np.ndarray, eps: float) -> np.ndarray:
y = np.empty_like(x)
y[x < -eps] = 0
mask = np.logical_and(-eps <= x, x <= eps)
y[mask] = 0.5*(1+x[mask]/eps+np.sin(np.pi*x[mask]/eps)/np.pi)
y[eps < x] = 1
return y
if __name__ == '__main__':
x = np.linspace(-2, 2, num=11)
print(f(x, 1))