Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math, time, re
- ln = lambda : raw_input()
- cnvi = lambda s: map(int, s.split())
- cnvf = lambda s: map(float, s.split())
- from math import pi, exp, sin
- '''
- (pi - x)/2 = Sum_1_INFINITY(1/n * sin(n x))
- '''
- print 'Input x, s, eps, eps1'
- l = cnvf(ln())
- x, s, e, e1 = l[0], l[1], l[2], l[3]
- a_n = lambda x, n: 1.0/n*sin(1.0*n*x)
- n, sum = 1, 0
- while abs(a_n(x,n)*exp(-(e*n)**s)) > e1:
- sum += a_n(x,n)*exp(-(e*n)**s)
- n += 1
- print (pi - x)/2, sum, n
Add Comment
Please, Sign In to add comment