write a code for a mac laurin for cosinusfor 5 iterations with math and not with numpy and plot in python
main.py
import math
import matplotlib.pyplot as plt
defcos_taylor(x, n): result = 0for i inrange(n):
coef = (-1) ** i
num = x ** (2*i)
denom = math.factorial(2*i)
result += coef * num / denom
return result
x_values = [i for i inrange(-10, 10)]
cos_values = [cos_taylor(math.radians(i), 5) for i in x_values]
plt.plot(x_values, cos_values)
plt.xlabel('x')
plt.ylabel('cos(x) estimate')
plt.title('Approximation of cos(x) using MacLaurin series')
plt.grid()
plt.show()