PDE by Fourier solution giving zero coeffiecant

Hi all,

I am working through a PDE and get through to the general solution, but get a seemingly zero Fourier coefficient.

$\displaystyle \frac {\partial u}{\partial t} = \frac {\partial^2 u}{\partial x^2}$

Using seperable variables method and setting the general solution $\displaystyle u(x,t) = X(x)T(t) = XT$ and substituting into original equation:

$\displaystyle \frac{X''}{X} = \frac {T'}{T} = -p^2$ where$\displaystyle -p^2$ is an arbitary constant. Solving the ODE's given yields:

$\displaystyle X = ACos(px) + Bsin(px)$ and $\displaystyle T = Ce^{-p^2t}$

$\displaystyle u(x,t) = XT = (YCos(px) + ZSin(px))e^{-p^2t} $

->Condition $\displaystyle u(0,t) =0 $ applied $\displaystyle => 0 = (Y +0) e^0=> Y = 0$

->now apply second condition $\displaystyle u(\pi,t) = 0$

$\displaystyle 0 = sin(\pi p) => n\pi = p\pi => n = p$ since $\displaystyle sin(n/pi}$ always satisfies the zero condition

$\displaystyle n= 1,2,3, 4 etc etc$ rewrite infinite solution as a fourier series.

$\displaystyle u(x,t) = \sum_{n =1,2,3, etc}^{\infty} QrSin(nx)e^{-p^2t}$

$\displaystyle u(x,0) = sin^2(x) ; 0<x<\pi$ evaluate $\displaystyle Qr$

$\displaystyle Qr = \frac{\pi}{2} \int_{o}^{\pi} sin^2(x)sin(2nx)$

I evaluated the $\displaystyle sin$ terms to simplify first:

$\displaystyle sin^2(x) = 1 - cos^2(x)$ subn

$\displaystyle = sin(2nx) - Cos^2(x)sin(2nx)$

but $\displaystyle cos^2{x} = 1/2 + 1/2cos(2x)$ subn

$\displaystyle = sin(2nx) -1/2sin(2nx)- 1/2cos(2x)sin(2nx) $

but $\displaystyle 1/2cos(2x)sin(2nx) = 1/4(sin(2x-2nx) -sin(2x+2nx)) $ subn

$\displaystyle = 1/2 sin(2nx) - 1/4(sin(2x-2nx) -sin(2x+2nx)) $ now back into integral:

$\displaystyle Qr = \frac{\pi}{2} \int_{o}^{\pi} 1/2 sin(2nx) - 1/4(sin(2x-2nx) -sin(2x+2nx)) $

$\displaystyle = \frac{\pi}{2} [-ncos(2nx) +1/4(2n-2)cos((2n-2)x)) - 1/4(2n+2)cos((2+2n)x)]_{0}^{\pi} $

It is this last part I always seem to have the expression collapsing to zero; since $\displaystyle cos(0)$ and $\displaystyle cos(n\pi)$ are always the same with the limits of $\displaystyle 0;\pi$

I know I must have made a mistake somewhere, I suspect in changing the period length and associated limits ,but can't see it!

Many thanks for reading.