#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import numpy as np
xi=-np.pi

fileread=open(sys.argv[1],'r')
ak=[]
bk=[]
x=[xi]
y=[]

for line in fileread:
 xj,yj,k=line.split()
 ak.append(float(xj))
 bk.append(float(yj))
delt=(np.pi-xi)/len(ak)

aux1=max(ak)/1000
aux2=max(bk)/1000

for i in xrange(0,len(ak)):
 if(aux1>ak[i]):
  ak[i]=0
 if(aux2>bk[i]):
  bk[i]=0

while(x[-1]<=np.pi+delt):
 soma=0
 for i in xrange(1,len(ak)):
  soma=soma+ak[i]*np.cos(2*np.pi*i*x[-1]/len(ak))+bk[i]*np.sin(2*np.pi*i*x[-1]/len(bk))
 soma=soma+ak[-1]*np.cos(i*x[-1])+ak[0]/2
 y.append(soma)
 print x[-1], y[-1]
 x.append(x[-1]+delt)

1ffaac2b4d5d4b121846d8500eef5d8f7a3f027c
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import numpy as np
xi=-np.pi

fileread=open(sys.argv[1],'r')
ak=[]
bk=[]
x=[xi]
y=[]

for line in fileread:
 xj,yj,k=line.split()
 ak.append(float(xj))
 bk.append(float(yj))
delt=(np.pi-xi)/len(ak)

aux1=max(ak)/1000
aux2=max(bk)/1000

for i in xrange(0,len(ak)):
 if(aux1>ak[i]):
  ak[i]=0
 if(aux2>bk[i]):
  bk[i]=0

while(x[-1]<=np.pi+delt):
 soma=0
 for i in xrange(1,len(ak)):
  soma=soma+ak[i]*np.cos(2*np.pi*i*x[-1]/len(ak))+bk[i]*np.sin(2*np.pi*i*x[-1]/len(bk))
 soma=soma+ak[-1]*np.cos(i*x[-1])+ak[0]/2
 y.append(soma)
 print x[-1], y[-1]
 x.append(x[-1]+delt)
