Advertisement
Guest User

Untitled

a guest
Dec 29th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. """
  2. 3*pi + SUM[n=0; n=INF]{(-1)^(n+1)*6*(x/2)^(2*n+1) / (2*n+1)}
  3.  
  4. """
  5.  
  6. from math import *
  7.  
  8. x = float(input('x = '))
  9. eps = float(input('eps = '))
  10.  
  11. ### Sn = 6*(x/2)
  12. Sn = 0 ###
  13. S = 3*pi
  14. ### n= 1
  15. n=0 ###
  16.  
  17.  
  18. while True:
  19.     ### Sn = pow(-1, (n+1))*pow(Sn, (2*n+1)) / (2*n+1)
  20.     Sn = pow(-1, (n+1))*6*pow((x/2), (2*n + 1)) / (2*n+1)###
  21.     S += Sn
  22.     n += 1
  23.     if fabs(Sn) < eps:
  24.         break
  25.  
  26. ### zn = 6*atan(x/2)
  27. zn = 6*(pi/2-atan(x/2)) ###
  28. print('{0} {1:.4f}'.format('6*arcctg(x/2)= ', zn))
  29. print('{0} {1:.4f}'.format('S = ', S))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement