#Solving Half Range Expansions
L = var('L')
f = x**3
plot(f,(x,0,10))
assume(L>0)
c(x) = 0
s(x) = 0
for n in range(1,5):
    an = integrate((2*f(x)*cos((n*pi*x)/L))/L, (x,0,L))                          #Even Periodic Extension
    bn = integrate((2*f(x)*sin((n*pi*x)/L))/L, (x,0,L))                          #Odd  Periodic Extension
    
    c(x) = c(x) + an*cos((n*pi*x)/L)
    s(x) = s(x) + bn*sin((n*pi*x)/L)

print 'The half range Cosine expansion'
print c(x),
print "+..."
print 'The half range Sine expansion'
print s(x),
print "+..."

Kreyszig-10.4-24-U (last edited 2010-12-18 07:20:57 by ArnabBasu)