change function from continuous to discrete
if you take sampling frequency as 20Msamples/sec then sampling time Ts is
$$T_s=\frac{1}{f_s}\\T_s=\frac{1}{20\times10^6}\\T_s=50ns$$since the solution is till n=79 we can see that t=79*50=3950
From the continues time function this  Trt/2=50ns and T-Trt/2=3950ns hence we get 1 n=1 to 79 when n=0 we get the first case which is equal to 0.5 similarly of n=80.This can be see as$$
w_T(nT_s)=
\begin{cases}
    \sin^2(\frac{\pi}{2}(0.5 +\frac{n50ns}{100ns})),&amp; \text{if } -50\times10^{-6}&lt;n50\times10^{-6}&lt;50\times10^{-6}\\
    1,              &amp; \text{if  } 50\times10^{-6}\leq n50\times10^{-6}\leq 3950\times 10^{-6}\\
 \sin^2(\frac{\pi}{2}(0.5 -\frac{n50ns-4000ns}{100ns})),&amp;\text{if } other case
\end{cases}$$
which comes down to
$$
    w(n)=
\begin{cases}
    \sin^2(\frac{\pi}{2}(0.5 +\frac{n}{2})),&amp; \text{if } -1&lt;n&lt;1\\
    1,              &amp; \text{if  } 1\leq n\leq79\\
 \sin^2(\frac{\pi}{2}(0.5 -\frac{n-79}{2})),&amp;\text{if } 79&lt;n&lt;81  &amp; \text{otherwise}
\end{cases}
$$
In the above equation we can remove the $$-1&lt;n&lt;1$$as n=0 when n=0 w(0)=0.5 for n=1to78 w(n)=1.When n=80 the third one become zero.Hence you get the finalized expression.I hope this answers your question