#++++++++ Hecke algebras of type B2 with unequal parameters for T_0 and T_1 ++++++
R.<Q,q> = LaurentPolynomialRing(ZZ)
A = FreeAlgebra(R, 2,'x')
F = A.monoid()
T0, T1 = F.gens()
mons = [ F(1), T0, T1, T0*T1 , T1*T0, T0*T1*T0, T1*T0*T1, T0*T1*T0*T1]
r = len(mons)
M = MatrixSpace(R,r)
mats = [M(
          [0,1,0,0,0,0,0,0, # 1*T0 = T0
           Q,Q-1,0,0,0,0,0,0,  #T0*T0 = Q + (Q-1) T0
           0,0,0,0,1,0,0,0, # T1*T0 = T10
           0,0,0,0,0,1,0,0, #T01*T0 = T010
           0,0,Q,0,Q-1,0,0,0, #T10*T0 = QT1 + (Q-1) T10
           0,0,0,Q,0,Q-1,0,0, #T010*T0 = T01 ( Q + (Q-1) T0) = QT01 + (Q-1)T010 
           0,0,0,0,0,0,0,1, #T101*T0 = T0101
           0,0,0,0,0,0,Q,Q-1]), #T0101*T0 = T10100 = T101( Q + (Q-1) T0) = QT101 + (Q-1)T0101
        M([0,0,1,0,0,0,0,0, # F(1)*T1= T1, 
           0,0,0,1,0,0,0,0, # T0*T1= T01, 
           q,0,q-1,0,0,0,0,0, # T1*T1= (q-1)T1 + q, 
           0,q,0,q-1,0,0,0,0, # T01*T1= T011 = T0((q-1)T1 + q) = qT0 + (q-1) T01, 
           0,0,0,0,0,0,1,0, # T10*T1= T101, 
           0,0,0,0,0,0,0,1, # T010*T1= T0101, 
           0,0,0,0,q,0,q-1,0, # T101*T1= T10((q-1)T1 + q) = (q-1)T101 + qT10, 
           0,0,0,0,0,q,0,q-1] # T0101*T1= T010((q-1)T1 + q) = qT010 + (q-1)T0101
         ) 
       ]
H.<T0,T1> = A.quotient(mons,mats)
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#To compute ~z02
v20 = (1+T0)*(q+T1*T0*T1); 
    #v20 = q + q*T0 + T1*T0*T1 + T0*T1*T0*T1
    #v20^2 = (Q^2*q^2+2*Q*q^2+q^2) 
    #      + (Q^2*q^2+2*Q*q^2+q^2)*T0 
    #      + (Q^2*q^2-Q^2*q+Q*q^2-Q*q)*T1 
    #      + (Q^2*q^2-Q^2*q+Q*q^2-Q*q)*T0*T1 
    #      + (Q^2*q^2-Q^2*q+Q*q^2-Q*q)*T1*T0 
    #      + (Q^2*q^2-Q^2*q+Q*q^2-Q*q)*T0*T1*T0 
    #      + (Q^2*q^2-Q^2*q+Q*q^2+Q^2+Q+q)*T1*T0*T1 
    #      + (Q^2*q^2-Q^2*q+Q*q^2+Q^2+Q+q)*T0*T1*T0*T1

zt20 = (Q+1)*(q*(Q+1)+Q*(q-1)*T1)
    
#To compute ~z11
v11 = (1+T0)*T1*(Q-T0)
    #v11 = Q*T1 + Q*T0*T1 + (-1)*T1*T0 + (-1)*T0*T1*T0
    #v11*T1*v11 = (Q^3*q+Q^2*q^2+Q^2+Q*q)*T1 + (Q^3*q+Q^2*q^2+Q^2+Q*q)*T0*T1 + (-Q^2*q-Q*q^2-Q-q)*T1*T0 + (-Q^2*q-Q*q^2-Q-q)*T0*T1*T0
zt11 = (Q+q)*(Q*q+1)
    
#To compute ~z20
v02 = (Q-T0)*(Q*q-T1*T0*T1); 
    #v02 = Q^2*q + (-Q*q)*T0 + (-Q)*T1*T0*T1 + T0*T1*T0*T1
    #T1*v02 = Q^2*q*T1 + (-Q*q)*T0*T1 + (-Q*q)*T1*T0 + q*T0*T1*T0 + (-Q*q+Q)*T1*T0*T1 + (q-1)*T0*T1*T0*T1
    
    T1*v02
    
zt02 = (Q+1)*(q*(Q+1) + (q-1)*T1);

#A = q*(Q+1)
#B = (q-1)
#det = A*(A+(q-1)*B) - q*B^2;
#q*(Q+1) + (q-1)*(q-1)-(q-1)*T1
#q*(Q+1) + (q-1)*Q*(q-1)-Q*(q-1)*T1
fB = (Q+q^(-1))*(Q+1)*(Q+q); 
zt20i = q^(-2)*(Q*q^2-Q*q+Q+q -Q*(q-1)*T1); # zt20i = fB* \tilde{z}^{-1}_{20}
zt11i = q^(-1)*(Q+1); #  zt11i = fB* \tilde{z}^{-1}_{11}
zt02i = q^(-2)*(Q*q+q^2-q+1 - (q-1)*T1);
# zt02*zt02i - fB
# zt11*zt11i - fB
# zt20*zt20i - fB
E11 = v11*T1*zt11i; #E11 = fB*e11
    #E11 =(Q^2+Q) + (Q^2+Q)*T0 + (Q^2-Q^2*q^-1+Q-Q*q^-1)*T1 + (Q^2-Q^2*q^-1+Q-Q*q^-1)*T0*T1 + (-Q*q^-1-q^-1)*T1*T0*T1 + (-Q*q^-1-q^-1)*T0*T1*T0*T1 
    #E11^2 - fB*E11 #should be zero
E20 = v20*zt20i; #E20 = fB*e20
    #E20 = (Q*q-Q+Q*q^-1+1) + (Q*q-Q+Q*q^-1+1)*T0 + (-Q+Q*q^-1)*T1 + (-Q+Q*q^-1)*T0*T1 + (-Q+Q*q^-1)*T1*T0 + (-Q+Q*q^-1)*T0*T1*T0 + (Q*q^-1+q^-1)*T1*T0*T1 + (Q*q^-1+q^-1)*T0*T1*T0*T1
    #E20^2 - fB*E20 #should be zero
E02 = v02*zt02i; #E02 = fB*e02
    #E02 = (Q^3+Q^2*q-Q^2+Q^2*q^-1) + (-Q^2-Q*q+Q-Q*q^-1)*T0 + (-Q^2+Q^2*q^-1)*T1 + (Q-Q*q^-1)*T0*T1 + (Q-Q*q^-1)*T1*T0 + (-1+q^-1)*T0*T1*T0 + (-Q^2*q^-1-Q*q^-1)*T1*T0*T1 + (Q*q^-1+q^-1)*T0*T1*T0*T1
    #E02^2-fB*E02 #should be zero