Advertisement
Guest User

Ряды Тейлора cos x

a guest
Oct 13th, 2015
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. x = float(input())
  2.  
  3. def factorial(x):
  4.     if x == 0:
  5.         return 1
  6.     else:
  7.         return x * factorial(x - 1)
  8.  
  9. pi = 3.14159265359
  10. x = x - int(x / pi)//2 * 2*pi
  11.  
  12. cos = 0
  13. if x > pi:
  14.     x -= 2 * pi
  15. for n in range(20):
  16.     cos += ((-1) ** n * x ** (2*n)) / (factorial(2*n))
  17. print(cos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement