Casimir operator of a given Lie algebra and relation with its matrix representation 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.
 A: 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. (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 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.
A: It might be worthwhile to also give the standard description (I think I saw it in Serre's notes long ago) of Casimir in intrinsic, coordinate-free terms... which proves that it is certainly independendent of coordinates! First, given a simple Lie algebra $\mathfrak g$, the Killing form $B(,)$ is non-degenerate, so gives an isomorphism of $\mathfrak g$ and its dual by $x \to B(-,x)$. Also, recall the isomorphism of $\mathrm{End}(\mathfrak g)$ with $\mathfrak g \otimes \mathfrak g^*$ (also for any finite-dimensional vector space). Then we have a chain of $G$-equivariant maps
$$\mathrm{End}_{\mathbb R}(\mathfrak g) \to\mathfrak g\otimes \mathfrak g^* \to\mathfrak g\otimes \mathfrak g \subset \bigotimes^\bullet \mathfrak g\to U \mathfrak g.$$
The identity map in $\mathrm{End}(\mathfrak g)$ is $G$-invariant, so its image through these maps is also $G$-invariant in the universal enveloping algebra $U\mathfrak g$. That image is the Casimir element (which needs to be proven non-zero, either by Poincare-Birkhoff-Witt, or by giving a repn in which it does not map to $0$).
In any case, this gives an (Ad) $G$-invariant (or ad-$\mathfrak g$-invariant) element in the universal enveloping algebra.
Examination of the description of it does confirm that for any basis $\{x_i\}$ of $\mathfrak g$, with dual basis $\{x_i'\}$, Casimir can be written as $\sum_i x_i x'_i$.
