تابع با ضابطه $f\left( x \right)=\left\{ \begin{matrix}
ax+\sin \frac{\pi }{x}\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\frac{1}{2}\le x\lt 2 \\
-1\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,x=2 \\
b{{\cos }^{2}}\left( \frac{\pi }{2x} \right)-a\,\,\,\,\,\,\,\,\,\,\,2\lt x\lt 4 \\
\end{matrix} \right.$ در نقطه $x=2$ پیوسته است. $b$ کدام است؟