How do I get a cosine to peak up to a certain value as it hits 0? With the above code, the y-value peaks to infinity as it approaches 0.
import matplotlib.pyplot as plt
import numpy as np
amp = 1
time = np.linspace(-5, 5, 1000)
signal = np.cos(1 * np.pi * time) * abs(1/time)
plt.figure(figsize=(10, 10))
plt.ylim(-4, 4)
plt.plot(time, signal, color="black")
plt.savefig('output.png', bbox_inches='tight', pad_inches=0,
transparent=True)
Put another way, based on my google-fu, how can I create a symmetrical exponentially decaying sinusoid with a maximum y-value as it approaches 0?