Hello Haya,
The integral is very much defined for m=n. In that case you are integrating the function
which is well behaved and has a calculable integral.
The syms expression contains a denominator
which has a factor of
which is a cubic zero when m-->n. So when m--> n the numerator also has to be reducible to a factor of (n-m)^3 so that it can lead to a (so far) undetermined 0/0 form. With
assume(n,{'positive','integer'})
f = (1/pi)*sin(n*x/2)^2*(pi-x)^2;
you obtain
pi^2/3 - (n*(pi + pi*cos(2*n*pi)) - sin(2*n*pi) + (n^2*pi^2*sin(2*n*pi))/2)/(n^3*pi)
and after setting
sin(2*n*pi) = 0 cos(2*n*pi) = 1
(there must be a way to get syms to do this but I don't know what it is) this reduces to
which doesn't work for n = 0, but that case can be ignored since the integrand is 0.