I'm following Gilmore's recipe to compute the abstract Casimir operator of a given algebra (in this example, I refer to algebra su(2)). This recipe bring up a matrix representation of the algebra and my problem is that I obtain different results according to the specific matrix representation that I choose. To be more concrete, look at the difference between these two cases:
Consider the defining commutators: $$ [J_1,J_2]=iJ_3, \qquad [J_2,J_3]=iJ_1, \qquad [J_3,J_1]=iJ_2 $$ The following $3\times 3$ matrices are a representation of this algebra: $$ J_1=\left( \begin{array}{ccc} 0 & 0 & 0 \\ 0 & 0 & -i \\ 0 & i & 0 \\ \end{array} \right), \qquad J_2=\left( \begin{array}{ccc} 0 & 0 & i \\ 0 & 0 & 0 \\ -i & 0 & 0 \\ \end{array} \right), \qquad J_3= \left( \begin{array}{ccc} 0 & -i & 0 \\ i & 0 & 0 \\ 0 & 0 & 0 \\ \end{array} \right). $$ Applying Gilmore's method (see pag. 140), one can write matrix $$ X= \sum_{i=1}^3a_iJ_i, \qquad a_i\in\mathbb{R} $$ One therefore obtains: $$ X=\left( \begin{array}{ccc} 0 & -i a_3 & i a_2 \\ i a_3 & 0 & -i a_1 \\ -i a_2 & i a_1 & 0 \\ \end{array} \right) $$ At this point one computes the characteristic polynomial $$ P(\lambda)=\mathrm{det}(X-\lambda\mathbb{I})=-\lambda^3+\lambda(a_1^2+a_2^2+a_3^2) $$ Performing the substitution $a_i\to J_i$ in the coefficient of $\lambda$, as prescribed by the algorithm, one obtains that the algebra's Casimir is $$ C=\left( \begin{array}{ccc} 2 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 2 \\ \end{array} \right) $$ which indeed commutes with $J_i, \quad \forall i$. This scheme therefore gives a correct result.
Now consider the following alternative (but equivalent) definition of the algebra su(2):
$$ [J_+,J_-]=2 J_3, \qquad [J_3,J_+]=+J_+, \qquad [J_3,J_-]=-J_-. $$ The following $3\times 3$ matrices are a representation of this algebra: $$ J_+= \left( \begin{array}{ccc} 0 & 0 & -1 \\ 0 & 0 & 0 \\ 0 & 2 & 0 \\ \end{array} \right), \qquad J_-=\left( \begin{array}{ccc} 0 & 0 & 0 \\ 0 & 0 & 1 \\ -2 & 0 & 0 \\ \end{array} \right), \qquad J_3=\left( \begin{array}{ccc} 1 & 0 & 0 \\ 0 & -1 & 0 \\ 0 & 0 & 0 \\ \end{array} \right) $$ Introducing three unknown coefficients $a_+,\,a_-,\,a_3$, one can computes matrix $X$ and the characteristic polynomial $P(\lambda)$ as seen before. One obtains that $$ P(\lambda)= -\lambda^3 +\lambda(a_3^2+4a_+a_-) $$ At this point, one has to perform the substitution $a_i\to J_i$. Even if one takes into accunt the need for symmetrization, i.e. $a_+a_-\to (J_+J_-+J_-J_+)/2$, the algorithm retrieves an incorrect result, i.e. the following matrix $$ \bar{C}=\left( \begin{array}{ccc} 3 & 0 & 0 \\ 0 & 3 & 0 \\ 0 & 0 & 4 \\ \end{array} \right) $$ which does not commute with matrices $J_+$ and $J_-$ and so constitutes a wrong result.
My question is: why does the first way give the correct result but the second scheme does not work? Did I miss any hypothesis which is needed by Gilmore's algorithm? I suspect that the problem might be either in the use of $J_\pm$ as basis elements of algebra su(2) or in the substitutions $a^i\to J_i$ (the book uses, in fact, upper and lower indices, a formalism which I am not familiar with). Please, take into account that my target is to understand how to compute the abstract Casimir operator of a certain Lie algebra in an algorithmic way. The matrix representation of linear and quadratic operators is just auxiliary to reach the target but it is not my core business.