# Missing } inserted and missing $inserted using amsmath package I'm using Texmaker 4.5 over Ubuntu 15.10 and trying to compile some amsmath code: \begin{eqnarray*}$\underset{\mathbf{S}}{\operatorname{arg\,min}}$\displaystyle\sum\_{i=1}^{k} \sum\_{\mathbf x \in S\_i} \left\| \mathbf x - \boldsymbol\mu\_i \right\|^2 \end{eqnarray*}  When compiling, got both Missing } inserted and missing$ inserted in the line that begins with $\underset.... I guess I've escaped correctly all needed escapes; been trying to fix it for some minutes now with no success, wanted to check with someone more proficient at this. Thank you for your collaboration! • eqnarray is already math so you do not want $ (or \displaystyle) but it is usually better to avoid eqnarray and use align from the amsmath package. – David Carlisle Jan 14 '16 at 16:57
• Well the first thing that leaps out at me is you do not need to use $...$ within an eqnarray* environment. Also, is there any reason you're using \_? This will produce an _ character, rather than the subscript that I presume you want? Also \mathbf is not a switch, you want \mathbf{x} – Au101 Jan 14 '16 at 16:57

eqnarray is already math so you should not have \$ but (a) eqnarray should not be used, amsmath provides align and (b) there is no alignment here at all so you just want $ \[ \underset{\mathbf{S}}{\operatorname{arg\,min}} \sum_{i=1}^{k} \sum_{\mathbf{x} \in S_i} \| \mathbf{x} - \boldsymbol{\mu}_i \|^2$

Note _ for subscripts not \_