Sitisom

Численные методы

Sep 15th, 2020
887
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from math import fabs, sqrt
  2.  
  3.  
  4. def point(x, e):
  5.     pi = 3.141592
  6.     a = x
  7.     y = a
  8.     n = 0
  9.  
  10.     while fabs(a) > e:
  11.         q = - pow(x, 2) * (2*n + 1) / ((n + 1) * (2*n + 3))
  12.         a = q * a
  13.         y += a
  14.         n += 1
  15.  
  16.     print('x(%f): %f' % (x, y * 2/sqrt(pi)))
  17.  
  18.  
  19. if __name__ == '__main__':
  20.     e = 0.000001
  21.     point(0.2, e)
  22.     point(0.6, e)
  23.     point(0.8, e)
  24.  
RAW Paste Data