I've the following function $\text{U}\left(t\right)$ that is defined as posted in the picture:
My book tells me that the Fourier series looks like:
$$\tag{1}U(t)=\sum_{n=1}^{\infty}2 \hat{u} \dfrac{\tau}{T}\dfrac{\sin(\dfrac12 n \omega \tau)}{\dfrac12 n \omega \tau}\cos(n \omega t-\dfrac12 n \omega \tau) \ \ \ \text{with} \ \ \omega:=\dfrac{2 \pi}{T}.$$
Now, I used Mathematica to plot the function given by formula $(1)$ but I got something else (I set some values for the constants in the function and plot it for $t$) so not the thing I was supposed to get.
Where is the mistake in the series?

Understanding that $\omega=2*\pi /T$, then the formula in the book is just missing the constant term ${\hat u\,\frac{\tau }{T}}$.
The correct formula is in fact: $$u(t) = \hat u\,\frac{\tau }{T} + \sum\limits_{1\, \le \,n} {2\,\hat u\,\frac{\tau }{T}\frac{{\sin \frac{1}{2}n\,\omega \,\tau }}{{\frac{1}{2}n\,\omega \,\tau }}} \cos \left( {n\,\omega \,t - \frac{1}{2}n\,\omega \,\tau } \right) $$
p.s.:
with the further understanding that the function actually be: $$ u(t)\quad \left| {\;0 \le t < T} \right.\quad = \left\{ {\begin{array}{*{20}c} {\,\hat u} & {0 \le t < \tau } \\ 0 & {\tau \le t < T} \\ \end{array}} \right. $$ i.e. that the step starts from $t=0$, which from the picture is not so evident