f(x) = x 
f
h(x) = pi
h 
bn = pi
g(x)= a0
for n in range(1,5):
        
        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)+ h(x)

Kreyszig-10.4-2 (last edited 2010-12-18 07:24:09 by AmitTewari)