f(x) = x**2
f


a0 = integrate(f(x)/pi , (x,-pi,pi))

an = 0
bn = pi
g(x)= a0
for n in range(1,9):
        
        an = integrate(f(x)*cos(n*x)/pi, (x,-pi,pi))
        bn = integrate(f(x)*sin(n*x)/pi, (x,-pi,pi))    
                
        g(x) =  an*cos(n*pi/pi*x) + bn*sin(n*pi/pi*x) + g(x) 
        

print g(x) + a0

Kreyszig-10Review-17-U (last edited 2010-12-18 12:22:10 by AmitTewari)