I am trying to write a program that plots the graph for the equation
y = 5 * e^-t * cos(2 * pi * t)
I have to use import math and this is what I have:
import matplotlib.pyplot as plt
import math
x = range(10)
y = [5 * math.exp(-t) * math.cos(math.pi * 2 * t) for t in x]
plt.plot(x,y)
plt.show()
I do not get the graph that I want. I need x to increment by 0.1 but when I make range(0, 10, .1)
, it gives me an error that:
float cannot be interpreted as integer
How can I adjust my code so that my plot points are separated by 0.1?