Firstly i have defined a simple function below.
dotPro[a_, b_] := a[1]*b[1] + a[2]*b[2];
Then i create two terms using the above function.
t1=dotPro[q,σ];
t2=dotPro[ϵ,σ];
Then i have some rules regarding how these parameters multiply
r1 = Rule[σ[1]^2, 1];
r2 = Rule[σ[2]^2, 1];
r3 = Rule[σ[1] σ[2], I*σ[3]];
r4 =Rule[σ[2] σ[1], -I*σ[3]];
Now i expand the product
res = Expand[t1*t2]
Finally i apply the said rules to my expanded terms
res /. r1 /. r2 /. r3 /. r4
The answer i get is the following
(q[1] ϵ[1] + q[2] ϵ[2] + I q[2] ϵ[1] σ[3] + I q[1] ϵ[2] σ[3])
What i want to get is this(minus sign)
q[1] ϵ[1] + q[2] ϵ[2] -I q[2] ϵ[1] σ[3] + I q[1] ϵ[2] σ[3]
I know what the problem is,its related to mathematica assuming commutative product.so at the heart it deals with implementing non-commutative algebra.
So i did find a link to a package here but it was not working and i think this simple thing can be achieved without resort to any packages.
All i want is whenever there is a term with σ[1] σ[2] it should be replaced by I*σ[3] and for σ[2] σ[1] it should be replaced by -I*σ[3]
I tried to achieve it like this,but no success
list = {{1, 1}, {1, 2}, {2, 1}, {2, 2}};
t1[[#[[1]]]]*t2[[#[[2]]]] & /@ list /. r1 /. r2 /. r3 /. r4

[q[i],σ[j]],[q[i],ε[j]], and[σ[i],ε[j]]? – Hector Aug 30 '13 at 15:08σare exactly the matricesPauliMatrix[i], so it's easiest to realize this algebra using them explicitly. You can always re-express results of explicit matrix algebra in terms of the Pauli matrices because the latter (together withIdentityMatrix[2]orPauliMatrix[0]) form a basis of the space of $2\times 2$ matrices. – Jens Aug 30 '13 at 16:01