Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import log, sqrt
- # Declaring the 4 functions
- f1 = lambda n: n**2.5
- f2 = lambda n: sqrt(n)
- f3 = lambda n: n**2 + 10
- f4 = lambda n: (n**2) * log(n, 2)
- numbers = list(range(1, 101))
- # numbers = [1, 2, 3, .... , 99, 100]
- f1Values = [f1(n) for n in numbers]
- f2Values = [f2(n) for n in numbers]
- f3Values = [f3(n) for n in numbers]
- f4Values = [f4(n) for n in numbers]
- import matplotlib.pyplot as plt
- plt.plot(numbers, f1Values, label="f1(n) = n ^ 2.5")
- plt.plot(numbers, f2Values, label="f2(n) = sqrt(n)")
- plt.plot(numbers, f3Values, label="f3(n) = n ^ 2 + 10")
- plt.plot(numbers, f4Values, label="f4(n) = n ^ 2 * logn")
- plt.xlabel("n")
- plt.ylabel("f(n)")
- plt.legend()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement