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: 


1. 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.
2. 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.



Casimir operator of a given Lie algebra and relation with its matrix representation
I think that the reason for this discrepancy is that in the first basis all three vectors have the same norm (with respect to the Killing form) while in the second they do not. You should see the $a\_i$s as elements in the dual of your Lie algebra and so the last step should be mapping these elements to the *duals* of your basis elements. This is where norm discrepancies play a role. 


To be a little more specific: For any semisimple Lie algebra $\mathfrak{g}$ there exists a nondegenerate invariant symmetric form $B$ called [Killing form](https://en.wikipedia.org/wiki/Killing_form). (Which in your case is just a multiple of the trace form $B(X,Y) = \mathrm{Tr}\, XY.$) 


With such a form $B$ we have a concrete isomorphism $\mathfrak{g} \to \mathfrak{g}^\*$ given by $X \mapsto B(\,\\_\,,X).$ For a basis $X\_i$ of $\mathfrak{g}$, the dual basis $\alpha\_i^\*$ is canonically defined by the condition $\alpha\_i(X\_j) = \delta\_{ij}.$ So starting with an orthogonal basis $X\_i$ we see that the dual basis can be identified using the previous isomorphism with $X\_i / B(X\_i, X\_i)$. For a general basis $X\_i$ some elments $Y\_i$ are/represent the dual basis to $X\_i$ iff $B(X\_i, Y\_j) = \delta\_{ij}$. If you write this in coordinates you get 
$$
[X\_i]^T [B] [Y\_j] = \delta\_{ij} \mathrm{I}\_n,
$$
where $[X\_i] = e\_i$ and $[B] = (B(X\_i, X\_j))\_{i,j=1}^n$. But this equations shows that $[Y\_j] = [B]^{-1}[X\_j].$


Let me also clear the confusion from comments. The Casimir operator is an element of the universal enveloping algebra and as such it cannot be represented by a finite dimensional matrix. What you are effectively doing here is you are mapping this element into an endomorphism algebra of some representation (see [the universal property](https://en.wikipedia.org/wiki/Universal_enveloping_algebra#Universal_property) of enveloping algebras) and thus you should obtain multiple of the identity matrix. This multiple can be sometimes obtained directly by different means. E.g. for a quadratic Casimir of a complex simple Lie algebra and a highest weight representation there is a formula involving $\lambda, \rho$ and the Killing form.


