Nonsymmetric Macdonald polynomials - Combinatorics

Skip to content
Back to top
View this page
Edit this page

# Nonsymmetric Macdonald polynomials

AUTHORS:

- Anne Schilling and Nicolas M. Thiéry (2013): initial version

ACKNOWLEDGEMENTS:

The initial version of this code (together with `root_lattice_realization_algebras.Algebras` and `hecke_algebra_representation.HeckeAlgebraRepresentation`) was written by Anne Schilling and Nicolas M. Thiery during the ICERM Semester Program on “Automorphic Forms, Combinatorial Representation Theory and Multiple Dirichlet Series” (January 28, 2013 - May 3, 2013) with the help of Dan Bump, Ben Brubaker, Bogdan Ion, Dan Orr, Arun Ram, Siddhartha Sahi, and Mark Shimozono. Special thanks go to Bogdan Ion and Mark Shimozono for their patient explanations and hand computations to check the code.

class sage.combinat.root_system.non_symmetric_macdonald_polynomials.NonSymmetricMacdonaldPolynomials(KL, q, q1, q2, normalized)

  Bases: `CherednikOperatorsEigenvectors`

  Nonsymmetric Macdonald polynomials.

  INPUT:

  - `KL` – an affine Cartan type or the group algebra of a realization of the affine weight lattice

  - `q`, `q1`, `q2` – parameters in the base ring of the group algebra (default: `q`, `q1`, `q2`)

  - `normalized` – boolean (default: `True`); whether to normalize the result to have leading coefficient 1

  This implementation covers all reduced affine root systems. The polynomials are constructed recursively by the application of intertwining operators.

  Todo

  - Non-reduced case (Koornwinder polynomials).

  - Non-equal parameters for the affine Hecke algebra.

  - Choice of convention (dominant/anti-dominant, …).

  - More uniform implementation of the \(T_0^\vee\) operator.

  - Optimizations, in particular in the calculation of the eigenvalues for the recursion.

  EXAMPLES:

  We construct the family of nonsymmetric Macdonald polynomials in three variables in type \(A\):

  Sage

      sage: E = NonSymmetricMacdonaldPolynomials(["A",2,1])

  Python

      >>> from sage.all import *
      >>> E = NonSymmetricMacdonaldPolynomials(["A",Integer(2),Integer(1)])

  They are constructed as elements of the group algebra of the classical weight lattice \(L_0\) (or one of its realizations, such as the ambient space, which is used here) and indexed by elements of \(L_0\):

  Sage

      sage: L0 = E.keys(); L0
      Ambient space of the Root system of type ['A', 2]

  [Python]

      >>> from sage.all import *
      >>> L0 = E.keys(); L0
      Ambient space of the Root system of type ['A', 2]

  Here is the nonsymmetric Macdonald polynomial with leading term \([2,0,1]\):

  Sage

      sage: E[L0([2,0,1])]                                                            # needs sage.libs.gap
      -((q*q1+q*q2)/(-q*q1-q2))*B[(1, 1, 1)]
      - ((q1+q2)/(-q*q1-q2))*B[(2, 1, 0)] + B[(2, 0, 1)]

  Python

      >>> from sage.all import *
      >>> E[L0([Integer(2),Integer(0),Integer(1)])]                                                            # needs sage.libs.gap
      -((q*q1+q*q2)/(-q*q1-q2))*B[(1, 1, 1)]
      - ((q1+q2)/(-q*q1-q2))*B[(2, 1, 0)] + B[(2, 0, 1)]

  It can be seen as a polynomial (or in general a Laurent polynomial) by interpreting each term as an exponent vector. The parameter \(q\) is the exponential of the null (co)root, whereas \(q_1\) and \(q_2\) are the two eigenvalues of each generator \(T_i\) of the affine Hecke algebra (see the background section for details).

  By setting \(q_1=t\), \(q_2=-1\) and using the `root_lattice_realization_algebras.Algebras.ElementMethods.expand()` method, we recover the nonsymmetric Macdonald polynomial as computed by [HHL06]’s combinatorial formula:

  Sage

      sage: K = QQ['q,t'].fraction_field()
      sage: q,t = K.gens()
      sage: E = NonSymmetricMacdonaldPolynomials(["A",2,1], q=q, q1=t, q2=-1)
      sage: vars = K['x0,x1,x2'].gens()
      sage: E[L0([2,0,1])].expand(vars)                                               # needs sage.libs.gap
      (t - 1)/(q*t - 1)*x0^2*x1 + x0^2*x2 + (q*t - q)/(q*t - 1)*x0*x1*x2

      sage: from sage.combinat.sf.ns_macdonald import E                               # needs sage.combinat
      sage: E([2,0,1])                                                                # needs sage.combinat sage.groups
      (t - 1)/(q*t - 1)*x0^2*x1 + x0^2*x2 + (q*t - q)/(q*t - 1)*x0*x1*x2

  [Python]

      >>> from sage.all import *
      >>> K = QQ['q,t'].fraction_field()
      >>> q,t = K.gens()
      >>> E = NonSymmetricMacdonaldPolynomials(["A",Integer(2),Integer(1)], q=q, q1=t, q2=-Integer(1))
      >>> vars = K['x0,x1,x2'].gens()
      >>> E[L0([Integer(2),Integer(0),Integer(1)])].expand(vars)                                               # needs sage.libs.gap
      (t - 1)/(q*t - 1)*x0^2*x1 + x0^2*x2 + (q*t - q)/(q*t - 1)*x0*x1*x2

      >>> from sage.combinat.sf.ns_macdonald import E                               # needs sage.combinat
      >>> E([Integer(2),Integer(0),Integer(1)])                                                                # needs sage.combinat sage.groups
      (t - 1)/(q*t - 1)*x0^2*x1 + x0^2*x2 + (q*t - q)/(q*t - 1)*x0*x1*x2

  Here is a type \(G_2^{(1)}\) nonsymmetric Macdonald polynomial:

  Sage

      sage: E = NonSymmetricMacdonaldPolynomials(["G",2,1])
      sage: L0 = E.keys()
      sage: omega = L0.fundamental_weights()
      sage: E[omega[2] - omega[1]]
      -((q*q1^3*q2+q*q1^2*q2^2)/(q*q1^4-q2^4))*B[(0, 0, 0)] + B[(1, -1, 0)]
      - ((q1*q2^3+q2^4)/(q*q1^4-q2^4))*B[(1, 0, -1)]

  Python

      >>> from sage.all import *
      >>> E = NonSymmetricMacdonaldPolynomials(["G",Integer(2),Integer(1)])
      >>> L0 = E.keys()
      >>> omega = L0.fundamental_weights()
      >>> E[omega[Integer(2)] - omega[Integer(1)]]
      -((q*q1^3*q2+q*q1^2*q2^2)/(q*q1^4-q2^4))*B[(0, 0, 0)] + B[(1, -1, 0)]
      - ((q1*q2^3+q2^4)/(q*q1^4-q2^4))*B[(1, 0, -1)]

  Many more examples are given after the background section.

  See also

  - `sage.combinat.sf.ns_macdonald.E()`

  - `SymmetricFunctions.macdonald()`

  Background

  The polynomial module

  The nonsymmetric Macdonald polynomials are a distinguished basis of the “polynomial” module of the affine Hecke algebra. Given:

      - a ground ring `K`, which contains the input parameters `q, q_1, q_2`
      - an affine root system, specified by a Cartan type `C`
      - a realization `L` of the weight lattice of type `C`

  the polynomial module is the group algebra \(K[L_0]\) of the classical weight lattice \(L_0\) with coefficients in \(K\). It is isomorphic to the Laurent polynomial ring over \(K\) generated by the formal exponentials of any basis of \(L_0\).

  In our running example \(L\) is the ambient space of type \(C_2^{(1)}\):

  Sage

      sage: K = QQ['q,q1,q2'].fraction_field()
      sage: q, q1, q2 = K.gens()
      sage: C = CartanType(["C",2,1])
      sage: L = RootSystem(C).ambient_space(); L
      Ambient space of the Root system of type ['C', 2, 1]

      sage: L.simple_roots()
      Finite family {0: -2*e[0] + e['delta'], 1: e[0] - e[1], 2: 2*e[1]}
      sage: omega = L.fundamental_weights(); omega
      Finite family {0: e['deltacheck'],
                     1: e[0] + e['deltacheck'],
                     2: e[0] + e[1] + e['deltacheck']}

      sage: L0 = L.classical(); L0
      Ambient space of the Root system of type ['C', 2]
      sage: KL0 = L0.algebra(K); KL0
      Algebra of the Ambient space of the Root system of type ['C', 2]
      over Fraction Field of Multivariate Polynomial Ring in q, q1, q2 over Rational Field

  [Python]

      >>> from sage.all import *
      >>> K = QQ['q,q1,q2'].fraction_field()
      >>> q, q1, q2 = K.gens()
      >>> C = CartanType(["C",Integer(2),Integer(1)])
      >>> L = RootSystem(C).ambient_space(); L
      Ambient space of the Root system of type ['C', 2, 1]

      >>> L.simple_roots()
      Finite family {0: -2*e[0] + e['delta'], 1: e[0] - e[1], 2: 2*e[1]}
      >>> omega = L.fundamental_weights(); omega
      Finite family {0: e['deltacheck'],
                     1: e[0] + e['deltacheck'],
                     2: e[0] + e[1] + e['deltacheck']}

      >>> L0 = L.classical(); L0
      Ambient space of the Root system of type ['C', 2]
      >>> KL0 = L0.algebra(K); KL0
      Algebra of the Ambient space of the Root system of type ['C', 2]
      over Fraction Field of Multivariate Polynomial Ring in q, q1, q2 over Rational Field

  Affine Hecke algebra

  The affine Hecke algebra is generated by elements \(T_i\) for `i` in the set of affine Dynkin nodes. They satisfy the same braid relations as the simple reflections \(s_i\) of the affine Weyl group. The \(T_i\) satisfy the quadratic relation

  \[(T_i-q_1)\circ(T_i-q_2) = 0,\]

  where \(q_1\) and \(q_2\) are the input parameters. Some of the representation theory requires that \(q_1\) and \(q_2\) satisfy additional relations; typically one uses the specializations \(q_1=u\) and \(q_2=-1/u\) or \(q_1=t\) and \(q_2=-1\)). This can be achieved by constructing an appropriate field and passing \(q_1\) and \(q_2\) appropriately; see the examples. In principle, the parameter(s) could further depend on `i`; this is not yet implemented but the code has been designed in such a way that this feature is easy to add.

  Demazure-Lusztig operators

  The `i`-th Demazure-Lusztig operator is an operator on \(K[L]\) which interpolates between the reflection \(s_i\) and the Demazure operator \(\pi_i\) (see `root_lattice_realization.RootLatticeRealization.Algebras.ParentMethods.demazure_lusztig_operators()`).:

  Sage

      sage: KL = L.algebra(K); KL
      Algebra of the Ambient space of the Root system of type ['C', 2, 1]
      over Fraction Field of Multivariate Polynomial Ring in q, q1, q2 over Rational Field
      sage: T = KL.demazure_lusztig_operators(q1, q2)
      sage: x = KL.monomial(omega[1]); x
      B[e[0] + e['deltacheck']]
      sage: T[2](x)
      q1*B[e[0] + e['deltacheck']]
      sage: T[1](x)
      (q1+q2)*B[e[0] + e['deltacheck']] + q1*B[e[1] + e['deltacheck']]
      sage: T[0](x)
      q1*B[e[0] + e['deltacheck']]

  Python

      >>> from sage.all import *
      >>> KL = L.algebra(K); KL
      Algebra of the Ambient space of the Root system of type ['C', 2, 1]
      over Fraction Field of Multivariate Polynomial Ring in q, q1, q2 over Rational Field
      >>> T = KL.demazure_lusztig_operators(q1, q2)
      >>> x = KL.monomial(omega[Integer(1)]); x
      B[e[0] + e['deltacheck']]
      >>> T[Integer(2)](x)
      q1*B[e[0] + e['deltacheck']]
      >>> T[Integer(1)](x)
      (q1+q2)*B[e[0] + e['deltacheck']] + q1*B[e[1] + e['deltacheck']]
      >>> T[Integer(0)](x)
      q1*B[e[0] + e['deltacheck']]

  The affine Hecke algebra acts on \(K[L]\) by letting the generators \(T_i\) act by the Demazure-Lusztig operators. The class `sage.combinat.root_system.hecke_algebra_representation.HeckeAlgebraRepresentation` implements some simple generic features for representations of affine Hecke algebras defined by the action of their \(T\)-generators.:

  Sage

      sage: T
      A representation of the (q1, q2)-Hecke algebra of type ['C', 2, 1] on
       Algebra of the Ambient space of the Root system of type ['C', 2, 1] over
       Fraction Field of Multivariate Polynomial Ring in q, q1, q2 over Rational Field
      sage: type(T)
      <class 'sage.combinat.root_system.hecke_algebra_representation.HeckeAlgebraRepresentation'>
      sage: T._test_relations()                 # long time (1.3s)

  [Python]

      >>> from sage.all import *
      >>> T
      A representation of the (q1, q2)-Hecke algebra of type ['C', 2, 1] on
       Algebra of the Ambient space of the Root system of type ['C', 2, 1] over
       Fraction Field of Multivariate Polynomial Ring in q, q1, q2 over Rational Field
      >>> type(T)
      <class 'sage.combinat.root_system.hecke_algebra_representation.HeckeAlgebraRepresentation'>
      >>> T._test_relations()                 # long time (1.3s)

  Here we construct the operator \(q_1 T_2^{-1}\circ T_1^{-1}T_0\) from a signed reduced word:

  Sage

      sage: T.Tw([0,1,2],[1,-1,-1], q1^2)
      Generic endomorphism of Algebra of the Ambient space of the Root system of type ['C', 2, 1]
      over Fraction Field of Multivariate Polynomial Ring in q, q1, q2 over Rational Field

  Python

      >>> from sage.all import *
      >>> T.Tw([Integer(0),Integer(1),Integer(2)],[Integer(1),-Integer(1),-Integer(1)], q1**Integer(2))
      Generic endomorphism of Algebra of the Ambient space of the Root system of type ['C', 2, 1]
      over Fraction Field of Multivariate Polynomial Ring in q, q1, q2 over Rational Field

  (note the reversal of the word). Inverses are computed using the quadratic relation.

  Cherednik operators

  The affine Hecke algebra contains elements \(Y_\lambda\) indexed by the coroot lattice. Their action on \(K[L]\) is implemented in Sage:

  Sage

      sage: Y = T.Y(); Y
      Lazy family (...)_{i in Coroot lattice of the Root system of type ['C', 2, 1]}
      sage: alphacheck = Y.keys().simple_roots()
      sage: Y1 = Y[alphacheck[1]]
      sage: Y1(x)
      ((q1^2+2*q1*q2+q2^2)/(-q1*q2))*B[e[0] + e['deltacheck']]
      - ((q1^2+2*q1*q2+q2^2)/(-q2^2))*B[-e[1] + e['deltacheck']]
      - ((q1^2+q1*q2)/(-q2^2))*B[2*e[0] - e[1] - e['delta'] + e['deltacheck']]
      + ((q1^3+q1^2*q2)/(-q2^3))*B[e[0] - e['delta'] + e['deltacheck']]
      + ((q1^3+q1^2*q2)/(-q2^3))*B[e[0] - 2*e[1] - e['delta'] + e['deltacheck']]
      + ((q1+q2)/(-q2))*B[e[1] + e['deltacheck']]
      + ((q1^3+2*q1^2*q2+q1*q2^2)/(-q2^3))*B[-e[1] - e['delta'] + e['deltacheck']]
      + ((q1^3+q1^2*q2)/(-q2^3))*B[2*e[0] - e[1] - 2*e['delta'] + e['deltacheck']]
      + ((q1^3+2*q1^2*q2+q1*q2^2)/(-q2^3))*B[-e[0] - e['delta'] + e['deltacheck']]
      + ((q1^3+2*q1^2*q2+q1*q2^2)/(-q2^3))*B[e[0] - 2*e['delta'] + e['deltacheck']]
      + ((q1^3+q1^2*q2)/(-q2^3))*B[3*e[0] - 3*e['delta'] + e['deltacheck']]
      + ((q1^3+q1^2*q2)/(-q2^3))*B[-e[0] - 2*e[1] - e['delta'] + e['deltacheck']]
      + ((q1^3+q1^2*q2)/(-q2^3))*B[e[0] - 2*e[1] - 2*e['delta'] + e['deltacheck']]
      + (q1^3/(-q2^3))*B[3*e[0] - 2*e[1] - 3*e['delta'] + e['deltacheck']]

  [Python]

      >>> from sage.all import *
      >>> Y = T.Y(); Y
      Lazy family (...)_{i in Coroot lattice of the Root system of type ['C', 2, 1]}
      >>> alphacheck = Y.keys().simple_roots()
      >>> Y1 = Y[alphacheck[Integer(1)]]
      >>> Y1(x)
      ((q1^2+2*q1*q2+q2^2)/(-q1*q2))*B[e[0] + e['deltacheck']]
      - ((q1^2+2*q1*q2+q2^2)/(-q2^2))*B[-e[1] + e['deltacheck']]
      - ((q1^2+q1*q2)/(-q2^2))*B[2*e[0] - e[1] - e['delta'] + e['deltacheck']]
      + ((q1^3+q1^2*q2)/(-q2^3))*B[e[0] - e['delta'] + e['deltacheck']]
      + ((q1^3+q1^2*q2)/(-q2^3))*B[e[0] - 2*e[1] - e['delta'] + e['deltacheck']]
      + ((q1+q2)/(-q2))*B[e[1] + e['deltacheck']]
      + ((q1^3+2*q1^2*q2+q1*q2^2)/(-q2^3))*B[-e[1] - e['delta'] + e['deltacheck']]
      + ((q1^3+q1^2*q2)/(-q2^3))*B[2*e[0] - e[1] - 2*e['delta'] + e['deltacheck']]
      + ((q1^3+2*q1^2*q2+q1*q2^2)/(-q2^3))*B[-e[0] - e['delta'] + e['deltacheck']]
      + ((q1^3+2*q1^2*q2+q1*q2^2)/(-q2^3))*B[e[0] - 2*e['delta'] + e['deltacheck']]
      + ((q1^3+q1^2*q2)/(-q2^3))*B[3*e[0] - 3*e['delta'] + e['deltacheck']]
      + ((q1^3+q1^2*q2)/(-q2^3))*B[-e[0] - 2*e[1] - e['delta'] + e['deltacheck']]
      + ((q1^3+q1^2*q2)/(-q2^3))*B[e[0] - 2*e[1] - 2*e['delta'] + e['deltacheck']]
      + (q1^3/(-q2^3))*B[3*e[0] - 2*e[1] - 3*e['delta'] + e['deltacheck']]

  The Cherednik operators span a Laurent polynomial ring inside the affine Hecke algebra; namely \(\lambda\mapsto Y_\lambda\) is a group isomorphism from the classical root lattice (viewed additively) to the affine Hecke algebra (viewed multiplicatively). In practice, \(Y_\lambda\) is constructed by computing combinatorially its signed reduced word (and an overall scalar factor) using the periodic orientation of the alcove model in the coweight lattice (see `hecke_algebra_representation.HeckeAlgebraRepresentation.Y_lambdacheck()`):

  Sage

      sage: Lcheck = L.root_system.coweight_lattice()
      sage: w = Lcheck.reduced_word_of_translation(Lcheck(alphacheck[1])); w
      [0, 2, 1, 0, 2, 1]
      sage: Lcheck.signs_of_alcovewalk(w)
      [1, -1, 1, -1, 1, 1]

  Python

      >>> from sage.all import *
      >>> Lcheck = L.root_system.coweight_lattice()
      >>> w = Lcheck.reduced_word_of_translation(Lcheck(alphacheck[Integer(1)])); w
      [0, 2, 1, 0, 2, 1]
      >>> Lcheck.signs_of_alcovewalk(w)
      [1, -1, 1, -1, 1, 1]

  Level zero representation of the affine Hecke algebra

  The action of the affine Hecke algebra on \(K[L]\) induces an action on \(K[L_0]\): the action of \(T_i\) on \(X^\lambda\) for \(\lambda\) a classical weight in \(L_0\) is obtained by embedding the weight at level zero in the affine weight lattice (see `weight_lattice_realizations.WeightLatticeRealizations.ParentMethods.embed_at_level()`) applying the Demazure-Lusztig operator there, and projecting from \(K[L]\to K[L_0]\) mapping the exponential of \(\delta\) to \(q\) (see `root_lattice_realization_algebras.Algebras.ParentMethods.q_project()`). This is implemented in `root_lattice_realization_algebras.Algebras.ParentMethods.demazure_lusztig_operators_on_classical()`:

  Sage

      sage: T = KL.demazure_lusztig_operators_on_classical(q, q1,q2)
      sage: omega = L0.fundamental_weights()
      sage: x = KL0.monomial(omega[1])
      sage: T[0](x)
      -q*q2*B[(-1, 0)]

  [Python]

      >>> from sage.all import *
      >>> T = KL.demazure_lusztig_operators_on_classical(q, q1,q2)
      >>> omega = L0.fundamental_weights()
      >>> x = KL0.monomial(omega[Integer(1)])
      >>> T[Integer(0)](x)
      -q*q2*B[(-1, 0)]

  For classical nodes these are the usual Demazure-Lusztig operators:

  Sage

      sage: T[1](x)
      (q1+q2)*B[(1, 0)] + q1*B[(0, 1)]

  Python

      >>> from sage.all import *
      >>> T[Integer(1)](x)
      (q1+q2)*B[(1, 0)] + q1*B[(0, 1)]

  Nonsymmetric Macdonald polynomials

  We can now finally define the nonsymmetric Macdonald polynomials. Because the Cherednik operators commute (and there is no radical), they can be simultaneously diagonalized; namely, \(K[L_0]\) admits a \(K\)-basis of joint eigenvectors for the \(Y_\lambda\). For \(\mu \in L_0\), the nonsymmetric Macdonald polynomial \(E_\mu\) is the unique eigenvector of the family of Cherednik operators \(Y_\lambda\) having \(\mu\) as leading term:

  Sage

      sage: E = NonSymmetricMacdonaldPolynomials(KL, q, q1, q2); E
      The family of the Macdonald polynomials of type ['C', 2, 1]
       with parameters q, q1, q2

  [Python]

      >>> from sage.all import *
      >>> E = NonSymmetricMacdonaldPolynomials(KL, q, q1, q2); E
      The family of the Macdonald polynomials of type ['C', 2, 1]
       with parameters q, q1, q2

  Or for short:

  Sage

      sage: E = NonSymmetricMacdonaldPolynomials(C)

  Python

      >>> from sage.all import *
      >>> E = NonSymmetricMacdonaldPolynomials(C)

  Recursive construction of the nonsymmetric Macdonald polynomials

  The generators \(T_i\) of the affine Hecke algebra almost skew commute with the Cherednik operators. More precisely, one can deform them into the so-called intertwining operators:

  \[\tau_i = T_i - (q_1+q_2) \frac{Y_i^{a-1}}{1-Y_i^a}\,.\]

  (where \(a=1\) except for \(i=0\) in type \(BC\) where \(a=a_0=2\)) which satisfy the following skew commutation relations:

  \[\tau_i Y_\lambda = Y_{s_i\lambda} \tau_i \,.\]

  If \(s_i \mu \ne \mu\), applying \(\tau_i\) on an eigenvector \(E_\mu\) produces a new eigenvector (essentially \(E_{s_i\mu}\)) with a distinct eigenvalue. It follows that the eigenvectors indexed by an affine Weyl orbit of weights, may be recursively computed from a single weight in the orbit.

  In the case at hand, there is a little complication: namely, the simple reflections \(s_i\) acting at level 0 do not act transitively on classical weights; in fact the orbits for the classical Weyl group and for the affine Weyl group are the same. Thus, one can construct the nonsymmetric Macdonald polynomials for all weights from those for the classical dominant weights, but one is lacking a creation operator to construct the nonsymmetric Macdonald polynomials for dominant weights.

  Twisted Demazure-Lusztig operators

  To compensate for this, one needs to consider another affinization of the action of the classical Demazure-Lusztig operators \(T_1,\dots,T_n\), which gives rise to the double affine Hecke algebra. Following Cherednik, one adds another operator \(T_0^\vee\) implemented in: `root_lattice_realization_algebras.Algebras.ParentMethods.T0_check_on_basis()`. See also: `root_lattice_realization_algebras.Algebras.ParentMethods.twisted_demazure_lusztig_operators()`.

  Depending on the type (untwisted or not), this is a representation of the affine Hecke algebra for another affinization of the classical Cartan type. The corresponding action of the affine Weyl group – which is used to compute the recursion on \(\mu\) – occurs in the corresponding weight lattice realization:

  Sage

      sage: E.L()
      Ambient space of the Root system of type ['C', 2, 1]
      sage: E.L_prime()
      Coambient space of the Root system of type ['B', 2, 1]
      sage: E.L_prime().classical()
      Ambient space of the Root system of type ['C', 2]

  [Python]

      >>> from sage.all import *
      >>> E.L()
      Ambient space of the Root system of type ['C', 2, 1]
      >>> E.L_prime()
      Coambient space of the Root system of type ['B', 2, 1]
      >>> E.L_prime().classical()
      Ambient space of the Root system of type ['C', 2]

  See `L_prime()` and `cartan_type.CartanType_affine.other_affinization()`.

  REFERENCES:

  [HaimanICM]

  M. Haiman, Cherednik algebras, Macdonald polynomials and combinatorics, Proceedings of the International Congress of Mathematicians, Madrid 2006, Vol. III, 843-872.

  [HHL06] (1,2,3,4,5)

  J. Haglund, M. Haiman and N. Loehr, A combinatorial formula for nonsymmetric Macdonald polynomials, Amer. J. Math. 130, No. 2 (2008), 359-383.

  [LNSSS12]

  C. Lenart, S. Naito, D. Sagaki, A. Schilling, M. Shimozono, A uniform model for Kirillov-Reshetikhin crystals I: Lifting the parabolic quantum Bruhat graph, preprint arXiv 1211.2042 [math.QA]

  More examples

  We show how to create the nonsymmetric Macdonald polynomials in two different ways and check that they are the same:

  Sage

      sage: K = QQ['q,u'].fraction_field()
      sage: q, u = K.gens()
      sage: E = NonSymmetricMacdonaldPolynomials(['D',3,1], q, u, -1/u)
      sage: omega = E.keys().fundamental_weights()
      sage: E[omega[1]+omega[3]]
      -((q*u^2-q)/(-q*u^4+1))*B[(1/2, -1/2, 1/2)]
      - ((q*u^2-q)/(-q*u^4+1))*B[(1/2, 1/2, -1/2)] + B[(3/2, 1/2, 1/2)]

      sage: KL = RootSystem(["D",3,1]).ambient_space().algebra(K)
      sage: P = NonSymmetricMacdonaldPolynomials(KL, q, u, -1/u)
      sage: E[omega[1]+omega[3]] == P[omega[1]+omega[3]]
      True
      sage: E[E.keys()((0,1,-1))]
      -((q*u^2-q)/(-q*u^2+1))*B[(0, 0, 0)] - ((u^2-1)/(-q*u^2+1))*B[(1, 1, 0)]
      - ((u^2-1)/(-q*u^2+1))*B[(1, 0, -1)] + B[(0, 1, -1)]

  Python

      >>> from sage.all import *
      >>> K = QQ['q,u'].fraction_field()
      >>> q, u = K.gens()
      >>> E = NonSymmetricMacdonaldPolynomials(['D',Integer(3),Integer(1)], q, u, -Integer(1)/u)
      >>> omega = E.keys().fundamental_weights()
      >>> E[omega[Integer(1)]+omega[Integer(3)]]
      -((q*u^2-q)/(-q*u^4+1))*B[(1/2, -1/2, 1/2)]
      - ((q*u^2-q)/(-q*u^4+1))*B[(1/2, 1/2, -1/2)] + B[(3/2, 1/2, 1/2)]

      >>> KL = RootSystem(["D",Integer(3),Integer(1)]).ambient_space().algebra(K)
      >>> P = NonSymmetricMacdonaldPolynomials(KL, q, u, -Integer(1)/u)
      >>> E[omega[Integer(1)]+omega[Integer(3)]] == P[omega[Integer(1)]+omega[Integer(3)]]
      True
      >>> E[E.keys()((Integer(0),Integer(1),-Integer(1)))]
      -((q*u^2-q)/(-q*u^2+1))*B[(0, 0, 0)] - ((u^2-1)/(-q*u^2+1))*B[(1, 1, 0)]
      - ((u^2-1)/(-q*u^2+1))*B[(1, 0, -1)] + B[(0, 1, -1)]

  In type \(A\), there is also a combinatorial implementation of the nonsymmetric Macdonald polynomials in terms of augmented diagram fillings as in [HHL06]. See `sage.combinat.sf.ns_macdonald.E()`. First we check that these polynomials are indeed eigenvectors of the Cherednik operators:

  Sage

      sage: K = QQ['q,t'].fraction_field()
      sage: q,t = K.gens()
      sage: q1 = t; q2 = -1
      sage: KL = RootSystem(["A",2,1]).ambient_space().algebra(K)
      sage: KL0 = KL.classical()
      sage: E = NonSymmetricMacdonaldPolynomials(KL,q, q1, q2)
      sage: omega = E.keys().fundamental_weights()
      sage: w = omega[1]

      sage: # needs sage.combinat sage.groups
      sage: import sage.combinat.sf.ns_macdonald as NS
      sage: p = NS.E([1,0,0]); p
      x0
      sage: pp = KL0.from_polynomial(p)
      sage: E.eigenvalues(KL0.from_polynomial(p))
      [t, (-1)/(-q*t^2), t]

      sage: def eig(l): return E.eigenvalues(KL0.from_polynomial(NS.E(l)))

      sage: # needs sage.combinat sage.groups
      sage: eig([1,0,0])
      [t, (-1)/(-q*t^2), t]
      sage: eig([2,0,0])
      [q*t, (-1)/(-q^2*t^2), t]
      sage: eig([3,0,0])
      [q^2*t, (-1)/(-q^3*t^2), t]
      sage: eig([2,0,4])
      [(-1)/(-q^3*t), 1/(q^2*t), q^4*t^2]

  [Python]

      >>> from sage.all import *
      >>> K = QQ['q,t'].fraction_field()
      >>> q,t = K.gens()
      >>> q1 = t; q2 = -Integer(1)
      >>> KL = RootSystem(["A",Integer(2),Integer(1)]).ambient_space().algebra(K)
      >>> KL0 = KL.classical()
      >>> E = NonSymmetricMacdonaldPolynomials(KL,q, q1, q2)
      >>> omega = E.keys().fundamental_weights()
      >>> w = omega[Integer(1)]

      >>> # needs sage.combinat sage.groups
      >>> import sage.combinat.sf.ns_macdonald as NS
      >>> p = NS.E([Integer(1),Integer(0),Integer(0)]); p
      x0
      >>> pp = KL0.from_polynomial(p)
      >>> E.eigenvalues(KL0.from_polynomial(p))
      [t, (-1)/(-q*t^2), t]

      >>> def eig(l): return E.eigenvalues(KL0.from_polynomial(NS.E(l)))

      >>> # needs sage.combinat sage.groups
      >>> eig([Integer(1),Integer(0),Integer(0)])
      [t, (-1)/(-q*t^2), t]
      >>> eig([Integer(2),Integer(0),Integer(0)])
      [q*t, (-1)/(-q^2*t^2), t]
      >>> eig([Integer(3),Integer(0),Integer(0)])
      [q^2*t, (-1)/(-q^3*t^2), t]
      >>> eig([Integer(2),Integer(0),Integer(4)])
      [(-1)/(-q^3*t), 1/(q^2*t), q^4*t^2]

  Next we check explicitly that they agree with the current implementation:

  Sage

      sage: K = QQ['q','t'].fraction_field()
      sage: q,t = K.gens()
      sage: KL = RootSystem(["A",1,1]).ambient_lattice().algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL,q, t, -1)
      sage: L0 = E.keys()
      sage: KL0 = KL.classical()
      sage: P = K['x0,x1']
      sage: def EE(weight): return E[L0(weight)].expand(P.gens())

      sage: # needs sage.combinat
      sage: import sage.combinat.sf.ns_macdonald as NS
      sage: EE([0,0])
      1
      sage: NS.E([0,0])                                                               # needs sage.groups
      1
      sage: EE([1,0])
      x0
      sage: NS.E([1,0])                                                               # needs sage.groups
      x0
      sage: EE([0,1])
      (t - 1)/(q*t - 1)*x0 + x1
      sage: NS.E([0,1])                                                               # needs sage.groups
      (t - 1)/(q*t - 1)*x0 + x1
      sage: EE([2,0])
      x0^2 + (q*t - q)/(q*t - 1)*x0*x1
      sage: NS.E([2,0])                                                               # needs sage.groups
      x0^2 + (q*t - q)/(q*t - 1)*x0*x1

  Python

      >>> from sage.all import *
      >>> K = QQ['q','t'].fraction_field()
      >>> q,t = K.gens()
      >>> KL = RootSystem(["A",Integer(1),Integer(1)]).ambient_lattice().algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL,q, t, -Integer(1))
      >>> L0 = E.keys()
      >>> KL0 = KL.classical()
      >>> P = K['x0,x1']
      >>> def EE(weight): return E[L0(weight)].expand(P.gens())

      >>> # needs sage.combinat
      >>> import sage.combinat.sf.ns_macdonald as NS
      >>> EE([Integer(0),Integer(0)])
      1
      >>> NS.E([Integer(0),Integer(0)])                                                               # needs sage.groups
      1
      >>> EE([Integer(1),Integer(0)])
      x0
      >>> NS.E([Integer(1),Integer(0)])                                                               # needs sage.groups
      x0
      >>> EE([Integer(0),Integer(1)])
      (t - 1)/(q*t - 1)*x0 + x1
      >>> NS.E([Integer(0),Integer(1)])                                                               # needs sage.groups
      (t - 1)/(q*t - 1)*x0 + x1
      >>> EE([Integer(2),Integer(0)])
      x0^2 + (q*t - q)/(q*t - 1)*x0*x1
      >>> NS.E([Integer(2),Integer(0)])                                                               # needs sage.groups
      x0^2 + (q*t - q)/(q*t - 1)*x0*x1

  The same, directly in the ambient lattice with several shifts:

  Sage

      sage: E[L0([2,0])]                                                              # needs sage.combinat
      -((q*t-q)/(-q*t+1))*B[(1, 1)] + B[(2, 0)]
      sage: E[L0([1,-1])]                                                             # needs sage.combinat
      -((q*t-q)/(-q*t+1))*B[(0, 0)] + B[(1, -1)]
      sage: E[L0([0,-2])]                                                             # needs sage.combinat
      -((q*t-q)/(-q*t+1))*B[(-1, -1)] + B[(0, -2)]

  [Python]

      >>> from sage.all import *
      >>> E[L0([Integer(2),Integer(0)])]                                                              # needs sage.combinat
      -((q*t-q)/(-q*t+1))*B[(1, 1)] + B[(2, 0)]
      >>> E[L0([Integer(1),-Integer(1)])]                                                             # needs sage.combinat
      -((q*t-q)/(-q*t+1))*B[(0, 0)] + B[(1, -1)]
      >>> E[L0([Integer(0),-Integer(2)])]                                                             # needs sage.combinat
      -((q*t-q)/(-q*t+1))*B[(-1, -1)] + B[(0, -2)]

  Systematic checks with Sage’s implementation of [HHL06]:

  Sage

      sage: assert all(EE([x,y]) == NS.E([x,y])                                       # needs sage.combinat
      ....:            for d in range(5) for x,y in IntegerVectors(d,2))

  Python

      >>> from sage.all import *
      >>> assert all(EE([x,y]) == NS.E([x,y])                                       # needs sage.combinat
      ...            for d in range(Integer(5)) for x,y in IntegerVectors(d,Integer(2)))

  With the current implementation, we can compute nonsymmetric Macdonald polynomials for any type, for example for type \(E_6^{(1)}\):

  Sage

      sage: K = QQ['q,u'].fraction_field()
      sage: q, u = K.gens()
      sage: KL = RootSystem(["E",6,1]).weight_space(extended=True).algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL,q,u,-1/u)
      sage: L0 = E.keys()

      sage: E[L0.fundamental_weight(1).weyl_action([2,4,3,2,1])]
      -((u^2-1)/(-q*u^16+1))*B[-Lambda[1] + Lambda[3]]
      - ((u^2-1)/(-q*u^16+1))*B[Lambda[1]] + B[-Lambda[2] + Lambda[5]]
      - ((u^2-1)/(-q*u^16+1))*B[Lambda[2]
      - Lambda[4] + Lambda[5]] - ((u^2-1)/(-q*u^16+1))*B[-Lambda[3] + Lambda[4]]

      sage: E[L0.fundamental_weight(2).weyl_action([2,5,3,4,2])]      # long time (6s)
      -((q^2*u^20-q^2*u^18-q*u^2+q)/(-q^2*u^32+2*q*u^16-1))*B[0]
      + B[Lambda[1] - Lambda[3] + Lambda[4] - Lambda[5] + Lambda[6]]
      - ((u^2-1)/(-q*u^16+1))*B[Lambda[1] - Lambda[3] + Lambda[5]]
      - ((q*u^20-q*u^18-u^2+1)/(-q^2*u^32+2*q*u^16-1))*B[-Lambda[2] + Lambda[4]]
      - ((q*u^20-q*u^18-u^2+1)/(-q^2*u^32+2*q*u^16-1))*B[Lambda[2]]
      + ((u^4-2*u^2+1)/(q^2*u^32-2*q*u^16+1))*B[Lambda[3] - Lambda[4] + Lambda[5]]
      - ((u^2-1)/(-q*u^16+1))*B[Lambda[3] - Lambda[5] + Lambda[6]]
      sage: E[L0.fundamental_weight(1)+L0.fundamental_weight(6)]      # long time (13s)
      ((q^2*u^10-q^2*u^8-q^2*u^2+q^2)/(q^2*u^26-q*u^16-q*u^10+1))*B[0]
      - ((q*u^2-q)/(-q*u^10+1))*B[Lambda[1] - Lambda[2] + Lambda[6]]
      - ((q*u^2-q)/(-q*u^10+1))*B[Lambda[1] + Lambda[2] - Lambda[4] + Lambda[6]]
      - ((q*u^2-q)/(-q*u^10+1))*B[Lambda[1] - Lambda[3] + Lambda[4] - Lambda[5] + Lambda[6]]
      - ((q*u^2-q)/(-q*u^10+1))*B[Lambda[1] - Lambda[3] + Lambda[5]] + B[Lambda[1] + Lambda[6]]
      - ((q*u^2-q)/(-q*u^10+1))*B[-Lambda[2] + Lambda[4]]
      - ((q*u^2-q)/(-q*u^10+1))*B[Lambda[2]]
      - ((q*u^2-q)/(-q*u^10+1))*B[Lambda[3] - Lambda[4] + Lambda[5]]
      - ((q*u^2-q)/(-q*u^10+1))*B[Lambda[3] - Lambda[5] + Lambda[6]]

  [Python]

      >>> from sage.all import *
      >>> K = QQ['q,u'].fraction_field()
      >>> q, u = K.gens()
      >>> KL = RootSystem(["E",Integer(6),Integer(1)]).weight_space(extended=True).algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL,q,u,-Integer(1)/u)
      >>> L0 = E.keys()

      >>> E[L0.fundamental_weight(Integer(1)).weyl_action([Integer(2),Integer(4),Integer(3),Integer(2),Integer(1)])]
      -((u^2-1)/(-q*u^16+1))*B[-Lambda[1] + Lambda[3]]
      - ((u^2-1)/(-q*u^16+1))*B[Lambda[1]] + B[-Lambda[2] + Lambda[5]]
      - ((u^2-1)/(-q*u^16+1))*B[Lambda[2]
      - Lambda[4] + Lambda[5]] - ((u^2-1)/(-q*u^16+1))*B[-Lambda[3] + Lambda[4]]

      >>> E[L0.fundamental_weight(Integer(2)).weyl_action([Integer(2),Integer(5),Integer(3),Integer(4),Integer(2)])]      # long time (6s)
      -((q^2*u^20-q^2*u^18-q*u^2+q)/(-q^2*u^32+2*q*u^16-1))*B[0]
      + B[Lambda[1] - Lambda[3] + Lambda[4] - Lambda[5] + Lambda[6]]
      - ((u^2-1)/(-q*u^16+1))*B[Lambda[1] - Lambda[3] + Lambda[5]]
      - ((q*u^20-q*u^18-u^2+1)/(-q^2*u^32+2*q*u^16-1))*B[-Lambda[2] + Lambda[4]]
      - ((q*u^20-q*u^18-u^2+1)/(-q^2*u^32+2*q*u^16-1))*B[Lambda[2]]
      + ((u^4-2*u^2+1)/(q^2*u^32-2*q*u^16+1))*B[Lambda[3] - Lambda[4] + Lambda[5]]
      - ((u^2-1)/(-q*u^16+1))*B[Lambda[3] - Lambda[5] + Lambda[6]]
      >>> E[L0.fundamental_weight(Integer(1))+L0.fundamental_weight(Integer(6))]      # long time (13s)
      ((q^2*u^10-q^2*u^8-q^2*u^2+q^2)/(q^2*u^26-q*u^16-q*u^10+1))*B[0]
      - ((q*u^2-q)/(-q*u^10+1))*B[Lambda[1] - Lambda[2] + Lambda[6]]
      - ((q*u^2-q)/(-q*u^10+1))*B[Lambda[1] + Lambda[2] - Lambda[4] + Lambda[6]]
      - ((q*u^2-q)/(-q*u^10+1))*B[Lambda[1] - Lambda[3] + Lambda[4] - Lambda[5] + Lambda[6]]
      - ((q*u^2-q)/(-q*u^10+1))*B[Lambda[1] - Lambda[3] + Lambda[5]] + B[Lambda[1] + Lambda[6]]
      - ((q*u^2-q)/(-q*u^10+1))*B[-Lambda[2] + Lambda[4]]
      - ((q*u^2-q)/(-q*u^10+1))*B[Lambda[2]]
      - ((q*u^2-q)/(-q*u^10+1))*B[Lambda[3] - Lambda[4] + Lambda[5]]
      - ((q*u^2-q)/(-q*u^10+1))*B[Lambda[3] - Lambda[5] + Lambda[6]]

  We test various other types:

  Sage

      sage: K = QQ['q,u'].fraction_field()
      sage: q, u = K.gens()
      sage: KL = RootSystem(["A",5,2]).ambient_space().algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL, q, u, -1/u)
      sage: L0 = E.keys()
      sage: E[L0.fundamental_weight(2)]
      -((q*u^2-q)/(-q*u^8+1))*B[(0, 0, 0)] + B[(1, 1, 0)]
      sage: E[L0((0,-1,1))]                   # long time (1.5s)
      -((q^2*u^10-q^2*u^8+q*u^6-q*u^4-q*u^2-u^2+q+1)/(-q^3*u^12+q^2*u^8+q*u^4-1))*B[(0, 0, 0)]
      - ((u^2-1)/(-q*u^4+1))*B[(1, -1, 0)]
      + ((u^6-u^4-u^2+1)/(q^3*u^12-q^2*u^8-q*u^4+1))*B[(1, 1, 0)]
      + ((u^4-2*u^2+1)/(q^3*u^12-q^2*u^8-q*u^4+1))*B[(1, 0, -1)]
      + ((q^2*u^12-q^2*u^10-u^2+1)/(q^3*u^12-q^2*u^8-q*u^4+1))*B[(1, 0, 1)]
      + B[(0, -1, 1)]
      - ((u^2-1)/(-q^2*u^8+1))*B[(0, 1, -1)] - ((u^2-1)/(-q^2*u^8+1))*B[(0, 1, 1)]
      sage: K = QQ['q,u'].fraction_field()
      sage: q, u = K.gens()
      sage: KL = RootSystem(["E",6,2]).ambient_space().algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL,q,u,-1/u)
      sage: L0 = E.keys()
      sage: E[L0.fundamental_weight(4)]       # long time (5s)
      -((q^3*u^20-q^3*u^18-q^2*u^2+q^2)/(-q^3*u^28+q^2*u^22+q*u^6-1))*B[(0, 0, 0, 0)]
      - ((q*u^2-q)/(-q*u^6+1))*B[(1/2, 1/2, -1/2, -1/2)]
      - ((q*u^2-q)/(-q*u^6+1))*B[(1/2, 1/2, -1/2, 1/2)]
      - ((q*u^2-q)/(-q*u^6+1))*B[(1/2, 1/2, 1/2, -1/2)]
      - ((q*u^2-q)/(-q*u^6+1))*B[(1/2, 1/2, 1/2, 1/2)]
      + ((q*u^2-q)/(q*u^6-1))*B[(1, 0, 0, 0)] + B[(1, 1, 0, 0)]
      - ((q*u^2-q)/(-q*u^6+1))*B[(0, 1, 0, 0)]
      sage: E[L0((1,-1,0,0))]                 # long time (23s)
      ((q^3*u^18-q^3*u^16+q*u^4-q^2*u^2-2*q*u^2+q^2+q)/(q^3*u^18-q^2*u^12-q*u^6+1))*B[(0, 0, 0, 0)]
      - ((q^3*u^18-q^3*u^16-q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(1/2, -1/2, -1/2, -1/2)]
      - ((q^3*u^18-q^3*u^16-q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(1/2, -1/2, -1/2, 1/2)]
      + ((q^3*u^18-q^3*u^16-q*u^2+q)/(q^3*u^18-q^2*u^12-q*u^6+1))*B[(1/2, -1/2, 1/2, -1/2)]
      + ((q^3*u^18-q^3*u^16-q*u^2+q)/(q^3*u^18-q^2*u^12-q*u^6+1))*B[(1/2, -1/2, 1/2, 1/2)]
      + ((q*u^8-q*u^6-q*u^2+q)/(q^3*u^18-q^2*u^12-q*u^6+1))*B[(1/2, 1/2, -1/2, -1/2)]
      + ((q*u^8-q*u^6-q*u^2+q)/(q^3*u^18-q^2*u^12-q*u^6+1))*B[(1/2, 1/2, -1/2, 1/2)]
      - ((q*u^8-q*u^6-q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(1/2, 1/2, 1/2, -1/2)]
      - ((q*u^8-q*u^6-q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(1/2, 1/2, 1/2, 1/2)]
      - ((q^2*u^18-q^2*u^16+q*u^8-q*u^6-q*u^2-u^2+q+1)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(1, 0, 0, 0)]
      + B[(1, -1, 0, 0)] - ((u^2-1)/(-q^2*u^12+1))*B[(1, 1, 0, 0)]
      - ((u^2-1)/(-q^2*u^12+1))*B[(1, 0, -1, 0)]
      + ((u^2-1)/(q^2*u^12-1))*B[(1, 0, 1, 0)]
      - ((u^2-1)/(-q^2*u^12+1))*B[(1, 0, 0, -1)]
      - ((u^2-1)/(-q^2*u^12+1))*B[(1, 0, 0, 1)]
      - ((q*u^2-q)/(-q*u^6+1))*B[(0, -1, 0, 0)]
      - ((q*u^4-2*q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(0, 1, 0, 0)]
      - ((q*u^4-2*q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(0, 0, -1, 0)]
      - ((q*u^4-2*q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(0, 0, 1, 0)]
      - ((q*u^4-2*q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(0, 0, 0, -1)]
      - ((q*u^4-2*q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(0, 0, 0, 1)]

  Python

      >>> from sage.all import *
      >>> K = QQ['q,u'].fraction_field()
      >>> q, u = K.gens()
      >>> KL = RootSystem(["A",Integer(5),Integer(2)]).ambient_space().algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL, q, u, -Integer(1)/u)
      >>> L0 = E.keys()
      >>> E[L0.fundamental_weight(Integer(2))]
      -((q*u^2-q)/(-q*u^8+1))*B[(0, 0, 0)] + B[(1, 1, 0)]
      >>> E[L0((Integer(0),-Integer(1),Integer(1)))]                   # long time (1.5s)
      -((q^2*u^10-q^2*u^8+q*u^6-q*u^4-q*u^2-u^2+q+1)/(-q^3*u^12+q^2*u^8+q*u^4-1))*B[(0, 0, 0)]
      - ((u^2-1)/(-q*u^4+1))*B[(1, -1, 0)]
      + ((u^6-u^4-u^2+1)/(q^3*u^12-q^2*u^8-q*u^4+1))*B[(1, 1, 0)]
      + ((u^4-2*u^2+1)/(q^3*u^12-q^2*u^8-q*u^4+1))*B[(1, 0, -1)]
      + ((q^2*u^12-q^2*u^10-u^2+1)/(q^3*u^12-q^2*u^8-q*u^4+1))*B[(1, 0, 1)]
      + B[(0, -1, 1)]
      - ((u^2-1)/(-q^2*u^8+1))*B[(0, 1, -1)] - ((u^2-1)/(-q^2*u^8+1))*B[(0, 1, 1)]
      >>> K = QQ['q,u'].fraction_field()
      >>> q, u = K.gens()
      >>> KL = RootSystem(["E",Integer(6),Integer(2)]).ambient_space().algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL,q,u,-Integer(1)/u)
      >>> L0 = E.keys()
      >>> E[L0.fundamental_weight(Integer(4))]       # long time (5s)
      -((q^3*u^20-q^3*u^18-q^2*u^2+q^2)/(-q^3*u^28+q^2*u^22+q*u^6-1))*B[(0, 0, 0, 0)]
      - ((q*u^2-q)/(-q*u^6+1))*B[(1/2, 1/2, -1/2, -1/2)]
      - ((q*u^2-q)/(-q*u^6+1))*B[(1/2, 1/2, -1/2, 1/2)]
      - ((q*u^2-q)/(-q*u^6+1))*B[(1/2, 1/2, 1/2, -1/2)]
      - ((q*u^2-q)/(-q*u^6+1))*B[(1/2, 1/2, 1/2, 1/2)]
      + ((q*u^2-q)/(q*u^6-1))*B[(1, 0, 0, 0)] + B[(1, 1, 0, 0)]
      - ((q*u^2-q)/(-q*u^6+1))*B[(0, 1, 0, 0)]
      >>> E[L0((Integer(1),-Integer(1),Integer(0),Integer(0)))]                 # long time (23s)
      ((q^3*u^18-q^3*u^16+q*u^4-q^2*u^2-2*q*u^2+q^2+q)/(q^3*u^18-q^2*u^12-q*u^6+1))*B[(0, 0, 0, 0)]
      - ((q^3*u^18-q^3*u^16-q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(1/2, -1/2, -1/2, -1/2)]
      - ((q^3*u^18-q^3*u^16-q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(1/2, -1/2, -1/2, 1/2)]
      + ((q^3*u^18-q^3*u^16-q*u^2+q)/(q^3*u^18-q^2*u^12-q*u^6+1))*B[(1/2, -1/2, 1/2, -1/2)]
      + ((q^3*u^18-q^3*u^16-q*u^2+q)/(q^3*u^18-q^2*u^12-q*u^6+1))*B[(1/2, -1/2, 1/2, 1/2)]
      + ((q*u^8-q*u^6-q*u^2+q)/(q^3*u^18-q^2*u^12-q*u^6+1))*B[(1/2, 1/2, -1/2, -1/2)]
      + ((q*u^8-q*u^6-q*u^2+q)/(q^3*u^18-q^2*u^12-q*u^6+1))*B[(1/2, 1/2, -1/2, 1/2)]
      - ((q*u^8-q*u^6-q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(1/2, 1/2, 1/2, -1/2)]
      - ((q*u^8-q*u^6-q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(1/2, 1/2, 1/2, 1/2)]
      - ((q^2*u^18-q^2*u^16+q*u^8-q*u^6-q*u^2-u^2+q+1)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(1, 0, 0, 0)]
      + B[(1, -1, 0, 0)] - ((u^2-1)/(-q^2*u^12+1))*B[(1, 1, 0, 0)]
      - ((u^2-1)/(-q^2*u^12+1))*B[(1, 0, -1, 0)]
      + ((u^2-1)/(q^2*u^12-1))*B[(1, 0, 1, 0)]
      - ((u^2-1)/(-q^2*u^12+1))*B[(1, 0, 0, -1)]
      - ((u^2-1)/(-q^2*u^12+1))*B[(1, 0, 0, 1)]
      - ((q*u^2-q)/(-q*u^6+1))*B[(0, -1, 0, 0)]
      - ((q*u^4-2*q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(0, 1, 0, 0)]
      - ((q*u^4-2*q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(0, 0, -1, 0)]
      - ((q*u^4-2*q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(0, 0, 1, 0)]
      - ((q*u^4-2*q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(0, 0, 0, -1)]
      - ((q*u^4-2*q*u^2+q)/(-q^3*u^18+q^2*u^12+q*u^6-1))*B[(0, 0, 0, 1)]

  Next we test a twisted type (checked against Maple computation by Bogdan Ion for \(q_1=t^2\) and \(q_2=-1\)):

  Sage

      sage: E = NonSymmetricMacdonaldPolynomials(["A",5,2])
      sage: omega = E.keys()

      sage: E[omega[1]]
      B[(1, 0, 0)]

      sage: E[-omega[1]]
      B[(-1, 0, 0)]
      + ((q*q1^6+q*q1^5*q2+q1*q2^5+q2^6)/(q^3*q1^6+q^2*q1^5*q2+q*q1*q2^5+q2^6))*B[(1, 0, 0)]
      + ((q1+q2)/(q*q1+q2))*B[(0, -1, 0)] + ((q1+q2)/(q*q1+q2))*B[(0, 1, 0)]
      + ((q1+q2)/(q*q1+q2))*B[(0, 0, -1)] + ((q1+q2)/(q*q1+q2))*B[(0, 0, 1)]

      sage: E[omega[2]]
      -((q1*q2^3+q2^4)/(q*q1^4-q2^4))*B[(1, 0, 0)] + B[(0, 1, 0)]

      sage: E[-omega[2]]
      ((q^2*q1^7+q^2*q1^6*q2-q1*q2^6-q2^7)/(q^3*q1^7-q^2*q1^5*q2^2+q*q1^2*q2^5-q2^7))*B[(1, 0, 0)]
      + B[(0, -1, 0)]
      + ((q*q1^5*q2^2+q*q1^4*q2^3-q1*q2^6-q2^7)/(q^3*q1^7-q^2*q1^5*q2^2+q*q1^2*q2^5-q2^7))*B[(0, 1, 0)]
      - ((q1*q2+q2^2)/(q*q1^2-q2^2))*B[(0, 0, -1)]
      + ((q1*q2+q2^2)/(-q*q1^2+q2^2))*B[(0, 0, 1)]

      sage: E[-omega[1]-omega[2]]
      ((q^3*q1^6+q^3*q1^5*q2+2*q^2*q1^6+3*q^2*q1^5*q2-q^2*q1^4*q2^2-2*q^2*q1^3*q2^3-q*q1^5*q2-2*q*q1^4*q2^2+q*q1^3*q2^3+2*q*q1^2*q2^4-q*q1*q2^5-q*q2^6+q1^3*q2^3+q1^2*q2^4-2*q1*q2^5-2*q2^6)/(q^4*q1^6+q^3*q1^5*q2-q^3*q1^4*q2^2+q*q1^2*q2^4-q*q1*q2^5-q2^6))*B[(0, 0, 0)]
      + B[(-1, -1, 0)]
      + ((q*q1^4+q*q1^3*q2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(-1, 1, 0)]
      + ((q1+q2)/(q*q1+q2))*B[(-1, 0, -1)]
      - ((q1+q2)/(-q*q1-q2))*B[(-1, 0, 1)]
      + ((q*q1^4+q*q1^3*q2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(1, -1, 0)]
      + ((q^2*q1^6+q^2*q1^5*q2+q*q1^5*q2-q*q1^3*q2^3-q1^5*q2-q1^4*q2^2+q1^3*q2^3+q1^2*q2^4-q1*q2^5-q2^6)/(q^4*q1^6+q^3*q1^5*q2-q^3*q1^4*q2^2+q*q1^2*q2^4-q*q1*q2^5-q2^6))*B[(1, 1, 0)]
      + ((q*q1^4+2*q*q1^3*q2+q*q1^2*q2^2-q1^3*q2-q1^2*q2^2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(1, 0, -1)]
      + ((q*q1^4+2*q*q1^3*q2+q*q1^2*q2^2-q1^3*q2-q1^2*q2^2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(1, 0, 1)]
      + ((q1+q2)/(q*q1+q2))*B[(0, -1, -1)]
      + ((q1+q2)/(q*q1+q2))*B[(0, -1, 1)]
      + ((q*q1^4+2*q*q1^3*q2+q*q1^2*q2^2-q1^3*q2-q1^2*q2^2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(0, 1, -1)]
      + ((q*q1^4+2*q*q1^3*q2+q*q1^2*q2^2-q1^3*q2-q1^2*q2^2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(0, 1, 1)]

      sage: E[omega[1]-omega[2]]
      ((q^3*q1^7+q^3*q1^6*q2-q*q1*q2^6-q*q2^7)/(q^3*q1^7-q^2*q1^5*q2^2+q*q1^2*q2^5-q2^7))*B[(0, 0, 0)]
      + B[(1, -1, 0)]
      + ((q*q1^5*q2^2+q*q1^4*q2^3-q1*q2^6-q2^7)/(q^3*q1^7-q^2*q1^5*q2^2+q*q1^2*q2^5-q2^7))*B[(1, 1, 0)]
      - ((q1*q2+q2^2)/(q*q1^2-q2^2))*B[(1, 0, -1)]
      + ((q1*q2+q2^2)/(-q*q1^2+q2^2))*B[(1, 0, 1)]

      sage: E[omega[3]]
      -((q1*q2^2+q2^3)/(-q*q1^3-q2^3))*B[(1, 0, 0)]
      - ((q1*q2^2+q2^3)/(-q*q1^3-q2^3))*B[(0, 1, 0)] + B[(0, 0, 1)]

      sage: E[-omega[3]]
      ((q*q1^4*q2+q*q1^3*q2^2-q1*q2^4-q2^5)/(-q^2*q1^5-q2^5))*B[(1, 0, 0)]
      + ((q*q1^4*q2+q*q1^3*q2^2-q1*q2^4-q2^5)/(-q^2*q1^5-q2^5))*B[(0, 1, 0)]
      + B[(0, 0, -1)] - ((q1*q2^4+q2^5)/(-q^2*q1^5-q2^5))*B[(0, 0, 1)]

  [Python]

      >>> from sage.all import *
      >>> E = NonSymmetricMacdonaldPolynomials(["A",Integer(5),Integer(2)])
      >>> omega = E.keys()

      >>> E[omega[Integer(1)]]
      B[(1, 0, 0)]

      >>> E[-omega[Integer(1)]]
      B[(-1, 0, 0)]
      + ((q*q1^6+q*q1^5*q2+q1*q2^5+q2^6)/(q^3*q1^6+q^2*q1^5*q2+q*q1*q2^5+q2^6))*B[(1, 0, 0)]
      + ((q1+q2)/(q*q1+q2))*B[(0, -1, 0)] + ((q1+q2)/(q*q1+q2))*B[(0, 1, 0)]
      + ((q1+q2)/(q*q1+q2))*B[(0, 0, -1)] + ((q1+q2)/(q*q1+q2))*B[(0, 0, 1)]

      >>> E[omega[Integer(2)]]
      -((q1*q2^3+q2^4)/(q*q1^4-q2^4))*B[(1, 0, 0)] + B[(0, 1, 0)]

      >>> E[-omega[Integer(2)]]
      ((q^2*q1^7+q^2*q1^6*q2-q1*q2^6-q2^7)/(q^3*q1^7-q^2*q1^5*q2^2+q*q1^2*q2^5-q2^7))*B[(1, 0, 0)]
      + B[(0, -1, 0)]
      + ((q*q1^5*q2^2+q*q1^4*q2^3-q1*q2^6-q2^7)/(q^3*q1^7-q^2*q1^5*q2^2+q*q1^2*q2^5-q2^7))*B[(0, 1, 0)]
      - ((q1*q2+q2^2)/(q*q1^2-q2^2))*B[(0, 0, -1)]
      + ((q1*q2+q2^2)/(-q*q1^2+q2^2))*B[(0, 0, 1)]

      >>> E[-omega[Integer(1)]-omega[Integer(2)]]
      ((q^3*q1^6+q^3*q1^5*q2+2*q^2*q1^6+3*q^2*q1^5*q2-q^2*q1^4*q2^2-2*q^2*q1^3*q2^3-q*q1^5*q2-2*q*q1^4*q2^2+q*q1^3*q2^3+2*q*q1^2*q2^4-q*q1*q2^5-q*q2^6+q1^3*q2^3+q1^2*q2^4-2*q1*q2^5-2*q2^6)/(q^4*q1^6+q^3*q1^5*q2-q^3*q1^4*q2^2+q*q1^2*q2^4-q*q1*q2^5-q2^6))*B[(0, 0, 0)]
      + B[(-1, -1, 0)]
      + ((q*q1^4+q*q1^3*q2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(-1, 1, 0)]
      + ((q1+q2)/(q*q1+q2))*B[(-1, 0, -1)]
      - ((q1+q2)/(-q*q1-q2))*B[(-1, 0, 1)]
      + ((q*q1^4+q*q1^3*q2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(1, -1, 0)]
      + ((q^2*q1^6+q^2*q1^5*q2+q*q1^5*q2-q*q1^3*q2^3-q1^5*q2-q1^4*q2^2+q1^3*q2^3+q1^2*q2^4-q1*q2^5-q2^6)/(q^4*q1^6+q^3*q1^5*q2-q^3*q1^4*q2^2+q*q1^2*q2^4-q*q1*q2^5-q2^6))*B[(1, 1, 0)]
      + ((q*q1^4+2*q*q1^3*q2+q*q1^2*q2^2-q1^3*q2-q1^2*q2^2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(1, 0, -1)]
      + ((q*q1^4+2*q*q1^3*q2+q*q1^2*q2^2-q1^3*q2-q1^2*q2^2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(1, 0, 1)]
      + ((q1+q2)/(q*q1+q2))*B[(0, -1, -1)]
      + ((q1+q2)/(q*q1+q2))*B[(0, -1, 1)]
      + ((q*q1^4+2*q*q1^3*q2+q*q1^2*q2^2-q1^3*q2-q1^2*q2^2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(0, 1, -1)]
      + ((q*q1^4+2*q*q1^3*q2+q*q1^2*q2^2-q1^3*q2-q1^2*q2^2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(0, 1, 1)]

      >>> E[omega[Integer(1)]-omega[Integer(2)]]
      ((q^3*q1^7+q^3*q1^6*q2-q*q1*q2^6-q*q2^7)/(q^3*q1^7-q^2*q1^5*q2^2+q*q1^2*q2^5-q2^7))*B[(0, 0, 0)]
      + B[(1, -1, 0)]
      + ((q*q1^5*q2^2+q*q1^4*q2^3-q1*q2^6-q2^7)/(q^3*q1^7-q^2*q1^5*q2^2+q*q1^2*q2^5-q2^7))*B[(1, 1, 0)]
      - ((q1*q2+q2^2)/(q*q1^2-q2^2))*B[(1, 0, -1)]
      + ((q1*q2+q2^2)/(-q*q1^2+q2^2))*B[(1, 0, 1)]

      >>> E[omega[Integer(3)]]
      -((q1*q2^2+q2^3)/(-q*q1^3-q2^3))*B[(1, 0, 0)]
      - ((q1*q2^2+q2^3)/(-q*q1^3-q2^3))*B[(0, 1, 0)] + B[(0, 0, 1)]

      >>> E[-omega[Integer(3)]]
      ((q*q1^4*q2+q*q1^3*q2^2-q1*q2^4-q2^5)/(-q^2*q1^5-q2^5))*B[(1, 0, 0)]
      + ((q*q1^4*q2+q*q1^3*q2^2-q1*q2^4-q2^5)/(-q^2*q1^5-q2^5))*B[(0, 1, 0)]
      + B[(0, 0, -1)] - ((q1*q2^4+q2^5)/(-q^2*q1^5-q2^5))*B[(0, 0, 1)]

  Comparison with the energy function of crystals

  Next we test that the nonsymmetric Macdonald polynomials at \(t=0\) match with the one-dimensional configuration sums involving Kirillov-Reshetikhin crystals for various types. See [LNSSS12]:

  Sage

      sage: K = QQ['q,t'].fraction_field()
      sage: q,t = K.gens()
      sage: KL = RootSystem(["A",5,2]).ambient_space().algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL, q, t, -1)
      sage: omega = E.keys().fundamental_weights()
      sage: E[-omega[1]].map_coefficients(lambda x: x.subs(t=0))
      B[(-1, 0, 0)] + B[(1, 0, 0)] + B[(0, -1, 0)] + B[(0, 1, 0)]
       + B[(0, 0, -1)] + B[(0, 0, 1)]
      sage: E[-omega[2]].map_coefficients(lambda x: x.subs(t=0))      # long time (3s)
      (q+2)*B[(0, 0, 0)] + B[(-1, -1, 0)] + B[(-1, 1, 0)] + B[(-1, 0, -1)]
       + B[(-1, 0, 1)] + B[(1, -1, 0)] + B[(1, 1, 0)] + B[(1, 0, -1)] + B[(1, 0, 1)]
       + B[(0, -1, -1)] + B[(0, -1, 1)] + B[(0, 1, -1)] + B[(0, 1, 1)]

  Python

      >>> from sage.all import *
      >>> K = QQ['q,t'].fraction_field()
      >>> q,t = K.gens()
      >>> KL = RootSystem(["A",Integer(5),Integer(2)]).ambient_space().algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL, q, t, -Integer(1))
      >>> omega = E.keys().fundamental_weights()
      >>> E[-omega[Integer(1)]].map_coefficients(lambda x: x.subs(t=Integer(0)))
      B[(-1, 0, 0)] + B[(1, 0, 0)] + B[(0, -1, 0)] + B[(0, 1, 0)]
       + B[(0, 0, -1)] + B[(0, 0, 1)]
      >>> E[-omega[Integer(2)]].map_coefficients(lambda x: x.subs(t=Integer(0)))      # long time (3s)
      (q+2)*B[(0, 0, 0)] + B[(-1, -1, 0)] + B[(-1, 1, 0)] + B[(-1, 0, -1)]
       + B[(-1, 0, 1)] + B[(1, -1, 0)] + B[(1, 1, 0)] + B[(1, 0, -1)] + B[(1, 0, 1)]
       + B[(0, -1, -1)] + B[(0, -1, 1)] + B[(0, 1, -1)] + B[(0, 1, 1)]

  Sage

      sage: KL = RootSystem(["C",3,1]).ambient_space().algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL, q, t, -1)
      sage: omega = E.keys().fundamental_weights()
      sage: E[-omega[2]].map_coefficients(lambda x: x.subs(t=0))      # long time (5s)
      2*B[(0, 0, 0)] + B[(-1, -1, 0)] + B[(-1, 1, 0)] + B[(-1, 0, -1)]
      + B[(-1, 0, 1)] + B[(1, -1, 0)] + B[(1, 1, 0)] + B[(1, 0, -1)] + B[(1, 0, 1)]
      + B[(0, -1, -1)] + B[(0, -1, 1)] + B[(0, 1, -1)] + B[(0, 1, 1)]

  [Python]

      >>> from sage.all import *
      >>> KL = RootSystem(["C",Integer(3),Integer(1)]).ambient_space().algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL, q, t, -Integer(1))
      >>> omega = E.keys().fundamental_weights()
      >>> E[-omega[Integer(2)]].map_coefficients(lambda x: x.subs(t=Integer(0)))      # long time (5s)
      2*B[(0, 0, 0)] + B[(-1, -1, 0)] + B[(-1, 1, 0)] + B[(-1, 0, -1)]
      + B[(-1, 0, 1)] + B[(1, -1, 0)] + B[(1, 1, 0)] + B[(1, 0, -1)] + B[(1, 0, 1)]
      + B[(0, -1, -1)] + B[(0, -1, 1)] + B[(0, 1, -1)] + B[(0, 1, 1)]

  Sage

      sage: R = RootSystem(['C',3,1])
      sage: KL = R.weight_lattice(extended=True).algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL, q, t, -1)
      sage: omega = E.keys().fundamental_weights()
      sage: La = R.weight_space().basis()
      sage: LS = crystals.ProjectedLevelZeroLSPaths(2*La[1])
      sage: (E[-2*omega[1]].map_coefficients(lambda x: x.subs(t=0))   # long time (15s)
      ....:   == LS.one_dimensional_configuration_sum(q))
      True
      sage: LS = crystals.ProjectedLevelZeroLSPaths(La[1] + La[2])
      sage: (E[-omega[1] - omega[2]].map_coefficients(lambda x: x.subs(t=0))  # long time (45s)
      ....:   == LS.one_dimensional_configuration_sum(q))
      True

  Python

      >>> from sage.all import *
      >>> R = RootSystem(['C',Integer(3),Integer(1)])
      >>> KL = R.weight_lattice(extended=True).algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL, q, t, -Integer(1))
      >>> omega = E.keys().fundamental_weights()
      >>> La = R.weight_space().basis()
      >>> LS = crystals.ProjectedLevelZeroLSPaths(Integer(2)*La[Integer(1)])
      >>> (E[-Integer(2)*omega[Integer(1)]].map_coefficients(lambda x: x.subs(t=Integer(0)))   # long time (15s)
      ...   == LS.one_dimensional_configuration_sum(q))
      True
      >>> LS = crystals.ProjectedLevelZeroLSPaths(La[Integer(1)] + La[Integer(2)])
      >>> (E[-omega[Integer(1)] - omega[Integer(2)]].map_coefficients(lambda x: x.subs(t=Integer(0)))  # long time (45s)
      ...   == LS.one_dimensional_configuration_sum(q))
      True

  Sage

      sage: R = RootSystem(['C',2,1])
      sage: KL = R.weight_lattice(extended=True).algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL, q, t, -1)
      sage: omega = E.keys().fundamental_weights()
      sage: La = R.weight_space().basis()
      sage: for d in range(1,3):              # long time (45s)
      ....:     for x,y in IntegerVectors(d,2):
      ....:         weight = x*La[1]+y*La[2]
      ....:         weight0 = -x*omega[1]-y*omega[2]
      ....:         LS = crystals.ProjectedLevelZeroLSPaths(weight)
      ....:         assert (E[weight0].map_coefficients(lambda x:x.subs(t=0))
      ....:                  == LS.one_dimensional_configuration_sum(q))

  [Python]

      >>> from sage.all import *
      >>> R = RootSystem(['C',Integer(2),Integer(1)])
      >>> KL = R.weight_lattice(extended=True).algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL, q, t, -Integer(1))
      >>> omega = E.keys().fundamental_weights()
      >>> La = R.weight_space().basis()
      >>> for d in range(Integer(1),Integer(3)):              # long time (45s)
      ...     for x,y in IntegerVectors(d,Integer(2)):
      ...         weight = x*La[Integer(1)]+y*La[Integer(2)]
      ...         weight0 = -x*omega[Integer(1)]-y*omega[Integer(2)]
      ...         LS = crystals.ProjectedLevelZeroLSPaths(weight)
      ...         assert (E[weight0].map_coefficients(lambda x:x.subs(t=Integer(0)))
      ...                  == LS.one_dimensional_configuration_sum(q))

  Sage

      sage: R = RootSystem(['B',3,1])
      sage: KL = R.weight_lattice(extended=True).algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL, q, t, -1)
      sage: omega = E.keys().fundamental_weights()
      sage: La = R.weight_space().basis()

      sage: # needs sage.combinat
      sage: LS = crystals.ProjectedLevelZeroLSPaths(2*La[1])
      sage: (E[-2*omega[1]].map_coefficients(lambda x: x.subs(t=0))   # long time (23s)
      ....:   == LS.one_dimensional_configuration_sum(q))
      True
      sage: B = crystals.KirillovReshetikhin(['B',3,1],1,1)
      sage: T = crystals.TensorProduct(B,B)
      sage: (T.one_dimensional_configuration_sum(q)   # long time (2s)
      ....:   == LS.one_dimensional_configuration_sum(q))
      True

  Python

      >>> from sage.all import *
      >>> R = RootSystem(['B',Integer(3),Integer(1)])
      >>> KL = R.weight_lattice(extended=True).algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL, q, t, -Integer(1))
      >>> omega = E.keys().fundamental_weights()
      >>> La = R.weight_space().basis()

      >>> # needs sage.combinat
      >>> LS = crystals.ProjectedLevelZeroLSPaths(Integer(2)*La[Integer(1)])
      >>> (E[-Integer(2)*omega[Integer(1)]].map_coefficients(lambda x: x.subs(t=Integer(0)))   # long time (23s)
      ...   == LS.one_dimensional_configuration_sum(q))
      True
      >>> B = crystals.KirillovReshetikhin(['B',Integer(3),Integer(1)],Integer(1),Integer(1))
      >>> T = crystals.TensorProduct(B,B)
      >>> (T.one_dimensional_configuration_sum(q)   # long time (2s)
      ...   == LS.one_dimensional_configuration_sum(q))
      True

  Sage

      sage: R = RootSystem(['BC',3,2])
      sage: KL = R.weight_lattice(extended=True).algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL, q, t, -1)
      sage: omega = E.keys().fundamental_weights()
      sage: La = R.weight_space().basis()
      sage: LS = crystals.ProjectedLevelZeroLSPaths(2*La[1])                          # needs sage.combinat
      sage: (E[-2*omega[1]].map_coefficients(lambda x: x.subs(t=0))   # long time (21s), needs sage.combinat
      ....:   == LS.one_dimensional_configuration_sum(q))
      True

  [Python]

      >>> from sage.all import *
      >>> R = RootSystem(['BC',Integer(3),Integer(2)])
      >>> KL = R.weight_lattice(extended=True).algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL, q, t, -Integer(1))
      >>> omega = E.keys().fundamental_weights()
      >>> La = R.weight_space().basis()
      >>> LS = crystals.ProjectedLevelZeroLSPaths(Integer(2)*La[Integer(1)])                          # needs sage.combinat
      >>> (E[-Integer(2)*omega[Integer(1)]].map_coefficients(lambda x: x.subs(t=Integer(0)))   # long time (21s), needs sage.combinat
      ...   == LS.one_dimensional_configuration_sum(q))
      True

  Sage

      sage: R = RootSystem(CartanType(['BC',3,2]).dual())
      sage: KL = R.weight_space(extended=True).algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL, q, t, -1)
      sage: omega = E.keys().fundamental_weights()
      sage: La = R.weight_space().basis()

      sage: # long time, needs sage.combinat
      sage: LS = crystals.ProjectedLevelZeroLSPaths(2*La[1])
      sage: g = E[-2*omega[1]].map_coefficients(lambda x: x.subs(t=0))    # 30s
      sage: f = LS.one_dimensional_configuration_sum(q)                   # 1.5s
      sage: P = g.support()[0].parent()
      sage: B = P.algebra(q.parent())
      sage: sum(p[1]*B(P(p[0])) for p in f) == g
      True

  Python

      >>> from sage.all import *
      >>> R = RootSystem(CartanType(['BC',Integer(3),Integer(2)]).dual())
      >>> KL = R.weight_space(extended=True).algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL, q, t, -Integer(1))
      >>> omega = E.keys().fundamental_weights()
      >>> La = R.weight_space().basis()

      >>> # long time, needs sage.combinat
      >>> LS = crystals.ProjectedLevelZeroLSPaths(Integer(2)*La[Integer(1)])
      >>> g = E[-Integer(2)*omega[Integer(1)]].map_coefficients(lambda x: x.subs(t=Integer(0)))    # 30s
      >>> f = LS.one_dimensional_configuration_sum(q)                   # 1.5s
      >>> P = g.support()[Integer(0)].parent()
      >>> B = P.algebra(q.parent())
      >>> sum(p[Integer(1)]*B(P(p[Integer(0)])) for p in f) == g
      True

  Sage

      sage: C = CartanType(['G',2,1])
      sage: R = RootSystem(C.dual())
      sage: K = QQ['q,t'].fraction_field()
      sage: q,t = K.gens()
      sage: KL = R.weight_lattice(extended=True).algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL, q, t, -1)
      sage: omega = E.keys().fundamental_weights()
      sage: La = R.weight_space().basis()

      sage: # needs sage.combinat
      sage: LS = crystals.ProjectedLevelZeroLSPaths(2*La[1])
      sage: (E[-2*omega[1]].map_coefficients(lambda x: x.subs(t=0))           # long time (20s), not tested
      ....:   == LS.one_dimensional_configuration_sum(q)
      True
      sage: LS = crystals.ProjectedLevelZeroLSPaths(La[1] + La[2])
      sage: (E[-omega[1]-omega[2]].map_coefficients(lambda x: x.subs(t=0))    # long time (23s), not tested
      ....:   == LS.one_dimensional_configuration_sum(q))
      True

  [Python]

      >>> from sage.all import *
      >>> C = CartanType(['G',Integer(2),Integer(1)])
      >>> R = RootSystem(C.dual())
      >>> K = QQ['q,t'].fraction_field()
      >>> q,t = K.gens()
      >>> KL = R.weight_lattice(extended=True).algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL, q, t, -Integer(1))
      >>> omega = E.keys().fundamental_weights()
      >>> La = R.weight_space().basis()

      >>> # needs sage.combinat
      >>> LS = crystals.ProjectedLevelZeroLSPaths(Integer(2)*La[Integer(1)])
      >>> (E[-Integer(2)*omega[Integer(1)]].map_coefficients(lambda x: x.subs(t=Integer(0)))           # long time (20s), not tested
      ...   == LS.one_dimensional_configuration_sum(q)
      True
      >>> LS = crystals.ProjectedLevelZeroLSPaths(La[Integer(1)] + La[Integer(2)])
      >>> (E[-omega[Integer(1)]-omega[Integer(2)]].map_coefficients(lambda x: x.subs(t=Integer(0)))    # long time (23s), not tested
      ...   == LS.one_dimensional_configuration_sum(q))
      True

  The next test breaks if the energy is not scaled by the translation factor for dual type \(G_2^{(1)}\):

  Sage

      sage: LS = crystals.ProjectedLevelZeroLSPaths(2*La[1]+La[2])                    # needs sage.combinat
      sage: (E[-2*omega[1]-omega[2]].map_coefficients(lambda x: x.subs(t=0))  # long time (100s), not tested, needs sage.combinat
      ....:   == LS.one_dimensional_configuration_sum(q)
      True

      sage: R = RootSystem(['D',4,1])
      sage: KL = R.weight_lattice(extended=True).algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL, q, t, -1)
      sage: omega = E.keys().fundamental_weights()
      sage: La = R.weight_space().basis()
      sage: for d in range(1,2):              # long time (41s)
      ....:     for a,b,c,d in IntegerVectors(d,4):
      ....:         weight = a*La[1] + b*La[2] + c*La[3] + d*La[4]
      ....:         weight0 = -a*omega[1] - b*omega[2] - c*omega[3] - d*omega[4]
      ....:         LS = crystals.ProjectedLevelZeroLSPaths(weight)
      ....:         assert (E[weight0].map_coefficients(lambda x: x.subs(t=0))
      ....:                  == LS.one_dimensional_configuration_sum(q))

  Python

      >>> from sage.all import *
      >>> LS = crystals.ProjectedLevelZeroLSPaths(Integer(2)*La[Integer(1)]+La[Integer(2)])                    # needs sage.combinat
      >>> (E[-Integer(2)*omega[Integer(1)]-omega[Integer(2)]].map_coefficients(lambda x: x.subs(t=Integer(0)))  # long time (100s), not tested, needs sage.combinat
      ...   == LS.one_dimensional_configuration_sum(q)
      True

      >>> R = RootSystem(['D',Integer(4),Integer(1)])
      >>> KL = R.weight_lattice(extended=True).algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL, q, t, -Integer(1))
      >>> omega = E.keys().fundamental_weights()
      >>> La = R.weight_space().basis()
      >>> for d in range(Integer(1),Integer(2)):              # long time (41s)
      ...     for a,b,c,d in IntegerVectors(d,Integer(4)):
      ...         weight = a*La[Integer(1)] + b*La[Integer(2)] + c*La[Integer(3)] + d*La[Integer(4)]
      ...         weight0 = -a*omega[Integer(1)] - b*omega[Integer(2)] - c*omega[Integer(3)] - d*omega[Integer(4)]
      ...         LS = crystals.ProjectedLevelZeroLSPaths(weight)
      ...         assert (E[weight0].map_coefficients(lambda x: x.subs(t=Integer(0)))
      ...                  == LS.one_dimensional_configuration_sum(q))

  Todo

  add his notes in latex

  Sage

      sage: K = QQ['q,q1,q2'].fraction_field()
      sage: q,q1,q2=K.gens()
      sage: L = RootSystem(["A",4,2]).ambient_space()
      sage: L.cartan_type()
      ['BC', 2, 2]
      sage: L.null_root()
      2*e['delta']
      sage: L.simple_roots()
      Finite family {0: -e[0] + e['delta'], 1: e[0] - e[1], 2: 2*e[1]}
      sage: KL = L.algebra(K)
      sage: KL0 = KL.classical()
      sage: L0 = L.classical()
      sage: L0.cartan_type()
      ['C', 2]

      sage: E = NonSymmetricMacdonaldPolynomials(KL, q=q,q1=q1,q2=q2)
      sage: E.keys()
      Ambient space of the Root system of type ['C', 2]
      sage: E.keys().simple_roots()
      Finite family {1: (1, -1), 2: (0, 2)}
      sage: omega = E.keys().fundamental_weights()

      sage: E[0*omega[1]]
      B[(0, 0)]
      sage: E[omega[1]]
      -((q*q1*q2^3+q*q2^4)/(q^2*q1^4-q2^4))*B[(0, 0)] + B[(1, 0)]

      sage: E[2*omega[2]]  # not checked against Bogdan's notes, but a good self-consistency test  # long time
      -((q^12*q1^6+q^12*q1^5*q2-2*q^10*q1^5*q2-5*q^10*q1^4*q2^2-3*q^10*q1^3*q2^3-2*q^8*q1^5*q2-4*q^8*q1^4*q2^2-q^8*q1^3*q2^3+q^8*q1^2*q2^4-q^8*q1*q2^5-q^8*q2^6+q^6*q1^3*q2^3-q^6*q1^2*q2^4-4*q^6*q1*q2^5-2*q^6*q2^6-q^4*q1^3*q2^3-3*q^4*q1^2*q2^4-4*q^4*q1*q2^5-2*q^4*q2^6)/(-q^12*q1^6-q^10*q1^5*q2-q^8*q1^3*q2^3+q^6*q1^4*q2^2-q^6*q1^2*q2^4+q^4*q1^3*q2^3+q^2*q1*q2^5+q2^6))*B[(0, 0)]
      + ((q^7*q1^2*q2+2*q^7*q1*q2^2+q^7*q2^3+q^5*q1^2*q2+2*q^5*q1*q2^2+q^5*q2^3)/(-q^8*q1^3-q^6*q1^2*q2+q^2*q1*q2^2+q2^3))*B[(-1, 0)]
      - ((q^6*q1*q2+q^6*q2^2)/(q^6*q1^2-q2^2))*B[(-1, -1)]
      + ((q^6*q1^2*q2+2*q^6*q1*q2^2+q^6*q2^3+q^4*q1^2*q2+2*q^4*q1*q2^2+q^4*q2^3)/(-q^8*q1^3-q^6*q1^2*q2+q^2*q1*q2^2+q2^3))*B[(-1, 1)]
      - ((q^3*q1*q2+q^3*q2^2)/(q^6*q1^2-q2^2))*B[(-1, 2)]
      + ((q^7*q1^3+q^7*q1^2*q2-q^7*q1*q2^2-q^7*q2^3-2*q^5*q1^2*q2-4*q^5*q1*q2^2-2*q^5*q2^3-2*q^3*q1^2*q2-4*q^3*q1*q2^2-2*q^3*q2^3)/(q^8*q1^3+q^6*q1^2*q2-q^2*q1*q2^2-q2^3))*B[(1, 0)]
      + ((q^6*q1^2*q2+2*q^6*q1*q2^2+q^6*q2^3+q^4*q1^2*q2+2*q^4*q1*q2^2+q^4*q2^3)/(-q^8*q1^3-q^6*q1^2*q2+q^2*q1*q2^2+q2^3))*B[(1, -1)]
      + ((q^8*q1^3+q^8*q1^2*q2+q^6*q1^3+q^6*q1^2*q2-q^6*q1*q2^2-q^6*q2^3-2*q^4*q1^2*q2-4*q^4*q1*q2^2-2*q^4*q2^3-q^2*q1^2*q2-3*q^2*q1*q2^2-2*q^2*q2^3)/(q^8*q1^3+q^6*q1^2*q2-q^2*q1*q2^2-q2^3))*B[(1, 1)]
      + ((q^5*q1^2+q^5*q1*q2-q^3*q1*q2-q^3*q2^2-q*q1*q2-q*q2^2)/(q^6*q1^2-q2^2))*B[(1, 2)]
      - ((q^6*q1^2+q^6*q1*q2-q^4*q1*q2-q^4*q2^2-q^2*q1*q2-q^2*q2^2)/(-q^6*q1^2+q2^2))*B[(2, 0)]
      - ((q^3*q1*q2+q^3*q2^2)/(q^6*q1^2-q2^2))*B[(2, -1)]
      - ((q^5*q1^2+q^5*q1*q2-q^3*q1*q2-q^3*q2^2-q*q1*q2-q*q2^2)/(-q^6*q1^2+q2^2))*B[(2, 1)]
      + B[(2, 2)]
      + ((q^7*q1^2*q2+2*q^7*q1*q2^2+q^7*q2^3+q^5*q1^2*q2+2*q^5*q1*q2^2+q^5*q2^3)/(-q^8*q1^3-q^6*q1^2*q2+q^2*q1*q2^2+q2^3))*B[(0, -1)]
      + ((q^7*q1^3+q^7*q1^2*q2-q^7*q1*q2^2-q^7*q2^3-2*q^5*q1^2*q2-4*q^5*q1*q2^2-2*q^5*q2^3-2*q^3*q1^2*q2-4*q^3*q1*q2^2-2*q^3*q2^3)/(q^8*q1^3+q^6*q1^2*q2-q^2*q1*q2^2-q2^3))*B[(0, 1)]
      + ((q^6*q1^2+q^6*q1*q2-q^4*q1*q2-q^4*q2^2-q^2*q1*q2-q^2*q2^2)/(q^6*q1^2-q2^2))*B[(0, 2)]
      sage: E.recursion(2*omega[2])
      [0, 1, 0, 2, 1, 0, 2, 1, 0]

  [Python]

      >>> from sage.all import *
      >>> K = QQ['q,q1,q2'].fraction_field()
      >>> q,q1,q2=K.gens()
      >>> L = RootSystem(["A",Integer(4),Integer(2)]).ambient_space()
      >>> L.cartan_type()
      ['BC', 2, 2]
      >>> L.null_root()
      2*e['delta']
      >>> L.simple_roots()
      Finite family {0: -e[0] + e['delta'], 1: e[0] - e[1], 2: 2*e[1]}
      >>> KL = L.algebra(K)
      >>> KL0 = KL.classical()
      >>> L0 = L.classical()
      >>> L0.cartan_type()
      ['C', 2]

      >>> E = NonSymmetricMacdonaldPolynomials(KL, q=q,q1=q1,q2=q2)
      >>> E.keys()
      Ambient space of the Root system of type ['C', 2]
      >>> E.keys().simple_roots()
      Finite family {1: (1, -1), 2: (0, 2)}
      >>> omega = E.keys().fundamental_weights()

      >>> E[Integer(0)*omega[Integer(1)]]
      B[(0, 0)]
      >>> E[omega[Integer(1)]]
      -((q*q1*q2^3+q*q2^4)/(q^2*q1^4-q2^4))*B[(0, 0)] + B[(1, 0)]

      >>> E[Integer(2)*omega[Integer(2)]]  # not checked against Bogdan's notes, but a good self-consistency test  # long time
      -((q^12*q1^6+q^12*q1^5*q2-2*q^10*q1^5*q2-5*q^10*q1^4*q2^2-3*q^10*q1^3*q2^3-2*q^8*q1^5*q2-4*q^8*q1^4*q2^2-q^8*q1^3*q2^3+q^8*q1^2*q2^4-q^8*q1*q2^5-q^8*q2^6+q^6*q1^3*q2^3-q^6*q1^2*q2^4-4*q^6*q1*q2^5-2*q^6*q2^6-q^4*q1^3*q2^3-3*q^4*q1^2*q2^4-4*q^4*q1*q2^5-2*q^4*q2^6)/(-q^12*q1^6-q^10*q1^5*q2-q^8*q1^3*q2^3+q^6*q1^4*q2^2-q^6*q1^2*q2^4+q^4*q1^3*q2^3+q^2*q1*q2^5+q2^6))*B[(0, 0)]
      + ((q^7*q1^2*q2+2*q^7*q1*q2^2+q^7*q2^3+q^5*q1^2*q2+2*q^5*q1*q2^2+q^5*q2^3)/(-q^8*q1^3-q^6*q1^2*q2+q^2*q1*q2^2+q2^3))*B[(-1, 0)]
      - ((q^6*q1*q2+q^6*q2^2)/(q^6*q1^2-q2^2))*B[(-1, -1)]
      + ((q^6*q1^2*q2+2*q^6*q1*q2^2+q^6*q2^3+q^4*q1^2*q2+2*q^4*q1*q2^2+q^4*q2^3)/(-q^8*q1^3-q^6*q1^2*q2+q^2*q1*q2^2+q2^3))*B[(-1, 1)]
      - ((q^3*q1*q2+q^3*q2^2)/(q^6*q1^2-q2^2))*B[(-1, 2)]
      + ((q^7*q1^3+q^7*q1^2*q2-q^7*q1*q2^2-q^7*q2^3-2*q^5*q1^2*q2-4*q^5*q1*q2^2-2*q^5*q2^3-2*q^3*q1^2*q2-4*q^3*q1*q2^2-2*q^3*q2^3)/(q^8*q1^3+q^6*q1^2*q2-q^2*q1*q2^2-q2^3))*B[(1, 0)]
      + ((q^6*q1^2*q2+2*q^6*q1*q2^2+q^6*q2^3+q^4*q1^2*q2+2*q^4*q1*q2^2+q^4*q2^3)/(-q^8*q1^3-q^6*q1^2*q2+q^2*q1*q2^2+q2^3))*B[(1, -1)]
      + ((q^8*q1^3+q^8*q1^2*q2+q^6*q1^3+q^6*q1^2*q2-q^6*q1*q2^2-q^6*q2^3-2*q^4*q1^2*q2-4*q^4*q1*q2^2-2*q^4*q2^3-q^2*q1^2*q2-3*q^2*q1*q2^2-2*q^2*q2^3)/(q^8*q1^3+q^6*q1^2*q2-q^2*q1*q2^2-q2^3))*B[(1, 1)]
      + ((q^5*q1^2+q^5*q1*q2-q^3*q1*q2-q^3*q2^2-q*q1*q2-q*q2^2)/(q^6*q1^2-q2^2))*B[(1, 2)]
      - ((q^6*q1^2+q^6*q1*q2-q^4*q1*q2-q^4*q2^2-q^2*q1*q2-q^2*q2^2)/(-q^6*q1^2+q2^2))*B[(2, 0)]
      - ((q^3*q1*q2+q^3*q2^2)/(q^6*q1^2-q2^2))*B[(2, -1)]
      - ((q^5*q1^2+q^5*q1*q2-q^3*q1*q2-q^3*q2^2-q*q1*q2-q*q2^2)/(-q^6*q1^2+q2^2))*B[(2, 1)]
      + B[(2, 2)]
      + ((q^7*q1^2*q2+2*q^7*q1*q2^2+q^7*q2^3+q^5*q1^2*q2+2*q^5*q1*q2^2+q^5*q2^3)/(-q^8*q1^3-q^6*q1^2*q2+q^2*q1*q2^2+q2^3))*B[(0, -1)]
      + ((q^7*q1^3+q^7*q1^2*q2-q^7*q1*q2^2-q^7*q2^3-2*q^5*q1^2*q2-4*q^5*q1*q2^2-2*q^5*q2^3-2*q^3*q1^2*q2-4*q^3*q1*q2^2-2*q^3*q2^3)/(q^8*q1^3+q^6*q1^2*q2-q^2*q1*q2^2-q2^3))*B[(0, 1)]
      + ((q^6*q1^2+q^6*q1*q2-q^4*q1*q2-q^4*q2^2-q^2*q1*q2-q^2*q2^2)/(q^6*q1^2-q2^2))*B[(0, 2)]
      >>> E.recursion(Integer(2)*omega[Integer(2)])
      [0, 1, 0, 2, 1, 0, 2, 1, 0]

  Some tests that the \(T\) s are implemented properly by hand defining the \(Y\) s in terms of them:

  Sage

      sage: T = E._T_Y
      sage: Ye1     = T.Tw((1,2,1,0), scalar=(-1/(q1*q2))^2)
      sage: Ye2     = T.Tw((2,1,0,1), signs=(1,1,1,-1), scalar=(-1/(q1*q2)))
      sage: Yalpha0 = T.Tw((0,1,2,1), signs=(-1,-1,-1,-1), scalar=q^-1*(-q1*q2)^2)
      sage: Yalpha1 = T.Tw((1,2,0,1,2,0), signs=(1,1,-1,1,-1,1), scalar=-1/(q1*q2))
      sage: Yalpha2 = T.Tw((2,1,0,1,2,1,0,1), signs=(1,1,1,-1,1,1,1,-1),
      ....:                scalar=(1/(q1*q2))^2)

      sage: Ye1(KL0.one())
      q1^2/q2^2*B[(0, 0)]
      sage: Ye2(KL0.one())
      -q1/q2*B[(0, 0)]
      sage: Yalpha0(KL0.one())
      q2^2/(q*q1^2)*B[(0, 0)]
      sage: Yalpha1(KL0.one())
      -q1/q2*B[(0, 0)]
      sage: Yalpha2(KL0.one())
      q1^2/q2^2*B[(0, 0)]

  Python

      >>> from sage.all import *
      >>> T = E._T_Y
      >>> Ye1     = T.Tw((Integer(1),Integer(2),Integer(1),Integer(0)), scalar=(-Integer(1)/(q1*q2))**Integer(2))
      >>> Ye2     = T.Tw((Integer(2),Integer(1),Integer(0),Integer(1)), signs=(Integer(1),Integer(1),Integer(1),-Integer(1)), scalar=(-Integer(1)/(q1*q2)))
      >>> Yalpha0 = T.Tw((Integer(0),Integer(1),Integer(2),Integer(1)), signs=(-Integer(1),-Integer(1),-Integer(1),-Integer(1)), scalar=q**-Integer(1)*(-q1*q2)**Integer(2))
      >>> Yalpha1 = T.Tw((Integer(1),Integer(2),Integer(0),Integer(1),Integer(2),Integer(0)), signs=(Integer(1),Integer(1),-Integer(1),Integer(1),-Integer(1),Integer(1)), scalar=-Integer(1)/(q1*q2))
      >>> Yalpha2 = T.Tw((Integer(2),Integer(1),Integer(0),Integer(1),Integer(2),Integer(1),Integer(0),Integer(1)), signs=(Integer(1),Integer(1),Integer(1),-Integer(1),Integer(1),Integer(1),Integer(1),-Integer(1)),
      ...                scalar=(Integer(1)/(q1*q2))**Integer(2))

      >>> Ye1(KL0.one())
      q1^2/q2^2*B[(0, 0)]
      >>> Ye2(KL0.one())
      -q1/q2*B[(0, 0)]
      >>> Yalpha0(KL0.one())
      q2^2/(q*q1^2)*B[(0, 0)]
      >>> Yalpha1(KL0.one())
      -q1/q2*B[(0, 0)]
      >>> Yalpha2(KL0.one())
      q1^2/q2^2*B[(0, 0)]

  Testing the \(Y\) s directly:

  Sage

      sage: Y = E.Y()
      sage: Y.keys()
      Coroot lattice of the Root system of type ['BC', 2, 2]
      sage: alpha = Y.keys().simple_roots()
      sage: L(alpha[0])
      -2*e[0] + e['deltacheck']
      sage: L(alpha[1])
      e[0] - e[1]
      sage: L(alpha[2])
      e[1]
      sage: Y[alpha[0]].word
      (0, 1, 2, 1)
      sage: Y[alpha[0]].signs
      (-1, -1, -1, -1)
      sage: Y[alpha[0]].scalar   # mind that Sage's q is the usual q^{1/2}
      q1^2*q2^2/q
      sage: Y[alpha[0]](KL0.one())
      q2^2/(q*q1^2)*B[(0, 0)]

      sage: Y[alpha[1]].word
      (1, 2, 0, 1, 2, 0)
      sage: Y[alpha[1]].signs
      (1, 1, -1, 1, -1, 1)
      sage: Y[alpha[1]].scalar
      1/(-q1*q2)

      sage: Y[alpha[2]].word  # Bogdan says it should be the square of that; do we need to take translation factors into account or not?
      (2, 1, 0, 1)
      sage: Y[alpha[2]].signs
      (1, 1, 1, -1)
      sage: Y[alpha[2]].scalar
      1/(-q1*q2)

  [Python]

      >>> from sage.all import *
      >>> Y = E.Y()
      >>> Y.keys()
      Coroot lattice of the Root system of type ['BC', 2, 2]
      >>> alpha = Y.keys().simple_roots()
      >>> L(alpha[Integer(0)])
      -2*e[0] + e['deltacheck']
      >>> L(alpha[Integer(1)])
      e[0] - e[1]
      >>> L(alpha[Integer(2)])
      e[1]
      >>> Y[alpha[Integer(0)]].word
      (0, 1, 2, 1)
      >>> Y[alpha[Integer(0)]].signs
      (-1, -1, -1, -1)
      >>> Y[alpha[Integer(0)]].scalar   # mind that Sage's q is the usual q^{1/2}
      q1^2*q2^2/q
      >>> Y[alpha[Integer(0)]](KL0.one())
      q2^2/(q*q1^2)*B[(0, 0)]

      >>> Y[alpha[Integer(1)]].word
      (1, 2, 0, 1, 2, 0)
      >>> Y[alpha[Integer(1)]].signs
      (1, 1, -1, 1, -1, 1)
      >>> Y[alpha[Integer(1)]].scalar
      1/(-q1*q2)

      >>> Y[alpha[Integer(2)]].word  # Bogdan says it should be the square of that; do we need to take translation factors into account or not?
      (2, 1, 0, 1)
      >>> Y[alpha[Integer(2)]].signs
      (1, 1, 1, -1)
      >>> Y[alpha[Integer(2)]].scalar
      1/(-q1*q2)

  Checking the provided nonsymmetric Macdonald polynomial:

  Sage

      sage: E10 = KL0.monomial(L0((1,0))) + KL0( q*(1-(-q1/q2)) / (1-q^2*(-q1/q2)^4) )
      sage: E10 == E[omega[1]]
      True
      sage: E.eigenvalues(E10)  # not checked
      [q*q1^2/q2^2, q2^3/(-q^2*q1^3), q1/(-q2)]

  Python

      >>> from sage.all import *
      >>> E10 = KL0.monomial(L0((Integer(1),Integer(0)))) + KL0( q*(Integer(1)-(-q1/q2)) / (Integer(1)-q**Integer(2)*(-q1/q2)**Integer(4)) )
      >>> E10 == E[omega[Integer(1)]]
      True
      >>> E.eigenvalues(E10)  # not checked
      [q*q1^2/q2^2, q2^3/(-q^2*q1^3), q1/(-q2)]

  Checking T0check:

  Sage

      sage: T0check_on_basis = KL.T0_check_on_basis(q1,q2, convention='dominant')
      sage: T0check_on_basis.phi  # note: this is in fact a0 phi
      (2, 0)
      sage: T0check_on_basis.v    # what to match it with?
      (1,)
      sage: T0check_on_basis.j    # what to match it with?
      2
      sage: T0check_on_basis(KL0.basis().keys().zero())
      -q1^2/q2*B[(1, 0)]

      sage: T0check = E._T[0]
      sage: T0check(KL0.one())
      -q1^2/q2*B[(1, 0)]

  [Python]

      >>> from sage.all import *
      >>> T0check_on_basis = KL.T0_check_on_basis(q1,q2, convention='dominant')
      >>> T0check_on_basis.phi  # note: this is in fact a0 phi
      (2, 0)
      >>> T0check_on_basis.v    # what to match it with?
      (1,)
      >>> T0check_on_basis.j    # what to match it with?
      2
      >>> T0check_on_basis(KL0.basis().keys().zero())
      -q1^2/q2*B[(1, 0)]

      >>> T0check = E._T[Integer(0)]
      >>> T0check(KL0.one())
      -q1^2/q2*B[(1, 0)]

  Systematic tests of nonsymmetric Macdonald polynomials in type \(A_1^{(1)}\), in the weight lattice. Each time, we specify the eigenvalues for the action of \(Y_{\alpha_0}\), and \(Y_{\alpha_1}\):

  Sage

      sage: K = QQ['q','t'].fraction_field()
      sage: q,t = K.gens()
      sage: KL = RootSystem(["A",1,1]).weight_lattice(extended=True).algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL,q, t, -1)
      sage: omega = E.keys().fundamental_weights()

      sage: x = E[0*omega[1]]; x
      B[0]
      sage: E.eigenvalues(x)
      [1/(q*t), t]
      sage: x.is_one()
      True
      sage: x.parent()
      Algebra of the Weight lattice of the Root system of type ['A', 1]
      over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field
      sage: E[omega[1]]
      B[Lambda[1]]
      sage: E.eigenvalues(_)
      [t, 1/(q*t)]
      sage: E[2*omega[1]]
      -((q*t-q)/(-q*t+1))*B[0] + B[2*Lambda[1]]
      sage: E.eigenvalues(_)
      [q*t, 1/(q^2*t)]
      sage: E[3*omega[1]]
      -((q^2*t-q^2)/(-q^2*t+1))*B[-Lambda[1]]
      - ((q^2*t-q^2+q*t-q)/(-q^2*t+1))*B[Lambda[1]] + B[3*Lambda[1]]
      sage: E.eigenvalues(_)
      [q^2*t, 1/(q^3*t)]
      sage: E[4*omega[1]]
      ((q^5*t^2-q^5*t+q^4*t^2-2*q^4*t+q^3*t^2+q^4-2*q^3*t+q^3-q^2*t+q^2)/(q^5*t^2-q^3*t-q^2*t+1))*B[0]
      - ((q^3*t-q^3)/(-q^3*t+1))*B[-2*Lambda[1]]
      - ((q^3*t-q^3+q^2*t-q^2+q*t-q)/(-q^3*t+1))*B[2*Lambda[1]]
      + B[4*Lambda[1]]
      sage: E.eigenvalues(_)
      [q^3*t, 1/(q^4*t)]
      sage: E[6*omega[1]]
      -((q^12*t^3-q^12*t^2+q^11*t^3-2*q^11*t^2+2*q^10*t^3+q^11*t-4*q^10*t^2+2*q^9*t^3+2*q^10*t-5*q^9*t^2+2*q^8*t^3+4*q^9*t-6*q^8*t^2+q^7*t^3-q^9+5*q^8*t-5*q^7*t^2+q^6*t^3-q^8+6*q^7*t-4*q^6*t^2-2*q^7+5*q^6*t-2*q^5*t^2-2*q^6+4*q^5*t-q^4*t^2-2*q^5+2*q^4*t-q^4+q^3*t-q^3)/(-q^12*t^3+q^9*t^2+q^8*t^2+q^7*t^2-q^5*t-q^4*t-q^3*t+1))*B[0]
      - ((q^5*t-q^5)/(-q^5*t+1))*B[-4*Lambda[1]]
      + ((q^9*t^2-q^9*t+q^8*t^2-2*q^8*t+q^7*t^2+q^8-2*q^7*t+q^6*t^2+q^7-2*q^6*t+q^5*t^2+q^6-2*q^5*t+q^5-q^4*t+q^4)/(q^9*t^2-q^5*t-q^4*t+1))*B[-2*Lambda[1]]
      + ((q^9*t^2-q^9*t+q^8*t^2-2*q^8*t+2*q^7*t^2+q^8-3*q^7*t+2*q^6*t^2+q^7-4*q^6*t+2*q^5*t^2+2*q^6-4*q^5*t+q^4*t^2+2*q^5-3*q^4*t+q^3*t^2+2*q^4-2*q^3*t+q^3-q^2*t+q^2)/(q^9*t^2-q^5*t-q^4*t+1))*B[2*Lambda[1]]
      + ((q^5*t-q^5+q^4*t-q^4+q^3*t-q^3+q^2*t-q^2+q*t-q)/(q^5*t-1))*B[4*Lambda[1]]
      + B[6*Lambda[1]]
      sage: E.eigenvalues(_)
      [q^5*t, 1/(q^6*t)]
      sage: E[-omega[1]]
      B[-Lambda[1]] - ((t-1)/(-q*t+1))*B[Lambda[1]]
      sage: E.eigenvalues(_)
      [(-1)/(-q^2*t), q*t]

  Python

      >>> from sage.all import *
      >>> K = QQ['q','t'].fraction_field()
      >>> q,t = K.gens()
      >>> KL = RootSystem(["A",Integer(1),Integer(1)]).weight_lattice(extended=True).algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL,q, t, -Integer(1))
      >>> omega = E.keys().fundamental_weights()

      >>> x = E[Integer(0)*omega[Integer(1)]]; x
      B[0]
      >>> E.eigenvalues(x)
      [1/(q*t), t]
      >>> x.is_one()
      True
      >>> x.parent()
      Algebra of the Weight lattice of the Root system of type ['A', 1]
      over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field
      >>> E[omega[Integer(1)]]
      B[Lambda[1]]
      >>> E.eigenvalues(_)
      [t, 1/(q*t)]
      >>> E[Integer(2)*omega[Integer(1)]]
      -((q*t-q)/(-q*t+1))*B[0] + B[2*Lambda[1]]
      >>> E.eigenvalues(_)
      [q*t, 1/(q^2*t)]
      >>> E[Integer(3)*omega[Integer(1)]]
      -((q^2*t-q^2)/(-q^2*t+1))*B[-Lambda[1]]
      - ((q^2*t-q^2+q*t-q)/(-q^2*t+1))*B[Lambda[1]] + B[3*Lambda[1]]
      >>> E.eigenvalues(_)
      [q^2*t, 1/(q^3*t)]
      >>> E[Integer(4)*omega[Integer(1)]]
      ((q^5*t^2-q^5*t+q^4*t^2-2*q^4*t+q^3*t^2+q^4-2*q^3*t+q^3-q^2*t+q^2)/(q^5*t^2-q^3*t-q^2*t+1))*B[0]
      - ((q^3*t-q^3)/(-q^3*t+1))*B[-2*Lambda[1]]
      - ((q^3*t-q^3+q^2*t-q^2+q*t-q)/(-q^3*t+1))*B[2*Lambda[1]]
      + B[4*Lambda[1]]
      >>> E.eigenvalues(_)
      [q^3*t, 1/(q^4*t)]
      >>> E[Integer(6)*omega[Integer(1)]]
      -((q^12*t^3-q^12*t^2+q^11*t^3-2*q^11*t^2+2*q^10*t^3+q^11*t-4*q^10*t^2+2*q^9*t^3+2*q^10*t-5*q^9*t^2+2*q^8*t^3+4*q^9*t-6*q^8*t^2+q^7*t^3-q^9+5*q^8*t-5*q^7*t^2+q^6*t^3-q^8+6*q^7*t-4*q^6*t^2-2*q^7+5*q^6*t-2*q^5*t^2-2*q^6+4*q^5*t-q^4*t^2-2*q^5+2*q^4*t-q^4+q^3*t-q^3)/(-q^12*t^3+q^9*t^2+q^8*t^2+q^7*t^2-q^5*t-q^4*t-q^3*t+1))*B[0]
      - ((q^5*t-q^5)/(-q^5*t+1))*B[-4*Lambda[1]]
      + ((q^9*t^2-q^9*t+q^8*t^2-2*q^8*t+q^7*t^2+q^8-2*q^7*t+q^6*t^2+q^7-2*q^6*t+q^5*t^2+q^6-2*q^5*t+q^5-q^4*t+q^4)/(q^9*t^2-q^5*t-q^4*t+1))*B[-2*Lambda[1]]
      + ((q^9*t^2-q^9*t+q^8*t^2-2*q^8*t+2*q^7*t^2+q^8-3*q^7*t+2*q^6*t^2+q^7-4*q^6*t+2*q^5*t^2+2*q^6-4*q^5*t+q^4*t^2+2*q^5-3*q^4*t+q^3*t^2+2*q^4-2*q^3*t+q^3-q^2*t+q^2)/(q^9*t^2-q^5*t-q^4*t+1))*B[2*Lambda[1]]
      + ((q^5*t-q^5+q^4*t-q^4+q^3*t-q^3+q^2*t-q^2+q*t-q)/(q^5*t-1))*B[4*Lambda[1]]
      + B[6*Lambda[1]]
      >>> E.eigenvalues(_)
      [q^5*t, 1/(q^6*t)]
      >>> E[-omega[Integer(1)]]
      B[-Lambda[1]] - ((t-1)/(-q*t+1))*B[Lambda[1]]
      >>> E.eigenvalues(_)
      [(-1)/(-q^2*t), q*t]

  As expected, \(e^{-\omega}\) is not an eigenvector:

  Sage

      sage: E.eigenvalues(KL.classical().monomial(-omega[1]))
      Traceback (most recent call last):
      ...
      AssertionError

  [Python]

      >>> from sage.all import *
      >>> E.eigenvalues(KL.classical().monomial(-omega[Integer(1)]))
      Traceback (most recent call last):
      ...
      AssertionError

  We proceed by comparing against the examples from the appendix of [HHL06] in type \(A_2^{(1)}\):

  Sage

      sage: K = QQ['q','t'].fraction_field()
      sage: q,t = K.gens()
      sage: KL = RootSystem(["A",2,1]).ambient_space().algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL,q, t, -1)
      sage: L0 = E.keys()
      sage: omega = L0.fundamental_weights()
      sage: P = K['x0,x1,x2']
      sage: def EE(weight): return E[L0(weight)].expand(P.gens())

      sage: EE([0,0,0])
      1
      sage: EE([1,0,0])
      x0
      sage: EE([0,1,0])
      (t - 1)/(q*t^2 - 1)*x0 + x1
      sage: EE([0,0,1])
      (t - 1)/(q*t - 1)*x0 + (t - 1)/(q*t - 1)*x1 + x2
      sage: EE([1,1,0])
      x0*x1
      sage: EE([1,0,1])
      (t - 1)/(q*t^2 - 1)*x0*x1 + x0*x2
      sage: EE([0,1,1])
      (t - 1)/(q*t - 1)*x0*x1 + (t - 1)/(q*t - 1)*x0*x2 + x1*x2
      sage: EE([2,0,0])
      x0^2 + (q*t - q)/(q*t - 1)*x0*x1 + (q*t - q)/(q*t - 1)*x0*x2

      sage: EE([0,2,0])
      (t - 1)/(q^2*t^2 - 1)*x0^2
      + (q^2*t^3 - q^2*t^2 + q*t^2 - 2*q*t + q - t + 1)/(q^3*t^3 - q^2*t^2 - q*t + 1)*x0*x1
      + x1^2
      + (q*t^2 - 2*q*t + q)/(q^3*t^3 - q^2*t^2 - q*t + 1)*x0*x2
      + (q*t - q)/(q*t - 1)*x1*x2

  Python

      >>> from sage.all import *
      >>> K = QQ['q','t'].fraction_field()
      >>> q,t = K.gens()
      >>> KL = RootSystem(["A",Integer(2),Integer(1)]).ambient_space().algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL,q, t, -Integer(1))
      >>> L0 = E.keys()
      >>> omega = L0.fundamental_weights()
      >>> P = K['x0,x1,x2']
      >>> def EE(weight): return E[L0(weight)].expand(P.gens())

      >>> EE([Integer(0),Integer(0),Integer(0)])
      1
      >>> EE([Integer(1),Integer(0),Integer(0)])
      x0
      >>> EE([Integer(0),Integer(1),Integer(0)])
      (t - 1)/(q*t^2 - 1)*x0 + x1
      >>> EE([Integer(0),Integer(0),Integer(1)])
      (t - 1)/(q*t - 1)*x0 + (t - 1)/(q*t - 1)*x1 + x2
      >>> EE([Integer(1),Integer(1),Integer(0)])
      x0*x1
      >>> EE([Integer(1),Integer(0),Integer(1)])
      (t - 1)/(q*t^2 - 1)*x0*x1 + x0*x2
      >>> EE([Integer(0),Integer(1),Integer(1)])
      (t - 1)/(q*t - 1)*x0*x1 + (t - 1)/(q*t - 1)*x0*x2 + x1*x2
      >>> EE([Integer(2),Integer(0),Integer(0)])
      x0^2 + (q*t - q)/(q*t - 1)*x0*x1 + (q*t - q)/(q*t - 1)*x0*x2

      >>> EE([Integer(0),Integer(2),Integer(0)])
      (t - 1)/(q^2*t^2 - 1)*x0^2
      + (q^2*t^3 - q^2*t^2 + q*t^2 - 2*q*t + q - t + 1)/(q^3*t^3 - q^2*t^2 - q*t + 1)*x0*x1
      + x1^2
      + (q*t^2 - 2*q*t + q)/(q^3*t^3 - q^2*t^2 - q*t + 1)*x0*x2
      + (q*t - q)/(q*t - 1)*x1*x2

  Systematic checks with Sage’s implementation of [HHL06]:

  Sage

      sage: import sage.combinat.sf.ns_macdonald as NS                                # needs sage.combinat
      sage: assert all(EE([x,y,z]) == NS.E([x,y,z]) for d in range(5)         # long time (9s), needs sage.combinat
      ....:            for x,y,z in IntegerVectors(d,3))

  [Python]

      >>> from sage.all import *
      >>> import sage.combinat.sf.ns_macdonald as NS                                # needs sage.combinat
      >>> assert all(EE([x,y,z]) == NS.E([x,y,z]) for d in range(Integer(5))         # long time (9s), needs sage.combinat
      ...            for x,y,z in IntegerVectors(d,Integer(3)))

  We check that we get eigenvectors for generic \(q_1\), \(q_2\):

  Sage

      sage: K = QQ['q,q1,q2'].fraction_field()
      sage: q,q1,q2 = K.gens()
      sage: KL = RootSystem(["A",2,1]).ambient_space().algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL, q, q1, q2)
      sage: L0 = E.keys()
      sage: omega = L0.fundamental_weights()
      sage: E[2*omega[2]]
      -((q*q1+q*q2)/(-q*q1-q2))*B[(1, 2, 1)] - ((q*q1+q*q2)/(-q*q1-q2))*B[(2, 1, 1)] + B[(2, 2, 0)]
      sage: for d in range(4):                # long time (9s)
      ....:     for weight in IntegerVectors(d,3).map(list).map(L0):
      ....:         eigenvalues = E.eigenvalues(E[L0(weight)])

  Python

      >>> from sage.all import *
      >>> K = QQ['q,q1,q2'].fraction_field()
      >>> q,q1,q2 = K.gens()
      >>> KL = RootSystem(["A",Integer(2),Integer(1)]).ambient_space().algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL, q, q1, q2)
      >>> L0 = E.keys()
      >>> omega = L0.fundamental_weights()
      >>> E[Integer(2)*omega[Integer(2)]]
      -((q*q1+q*q2)/(-q*q1-q2))*B[(1, 2, 1)] - ((q*q1+q*q2)/(-q*q1-q2))*B[(2, 1, 1)] + B[(2, 2, 0)]
      >>> for d in range(Integer(4)):                # long time (9s)
      ...     for weight in IntegerVectors(d,Integer(3)).map(list).map(L0):
      ...         eigenvalues = E.eigenvalues(E[L0(weight)])

  Some type \(C\) calculations:

  Sage

      sage: K = QQ['q','t'].fraction_field()
      sage: q, t = K.gens()
      sage: KL = RootSystem(["C",2,1]).ambient_space().algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL,q, t, -1)
      sage: L0 = E.keys()
      sage: omega = L0.fundamental_weights()
      sage: E[0*omega[1]]
      B[(0, 0)]
      sage: E.eigenvalues(_)  # checked for i=0 with previous calculation
      [1/(q*t^3), t, t]
      sage: E[omega[1]]
      B[(1, 0)]
      sage: E.eigenvalues(_)  # not checked
      [t, 1/(q*t^3), t]

      sage: E[-omega[1]]           # consistent with before refactoring
      B[(-1, 0)] - ((t-1)/(-q*t+1))*B[(1, 0)] - ((t-1)/(-q*t+1))*B[(0, -1)]
      + ((t-1)/(q*t-1))*B[(0, 1)]
      sage: E.eigenvalues(_)  # not checked
      [(-1)/(-q^2*t^3), q*t, t]
      sage: E[-omega[1]+omega[2]]  # consistent with before refactoring
      -((t-1)/(-q*t^3+1))*B[(1, 0)] + B[(0, 1)]
      sage: E.eigenvalues(_)  # not checked
      [t, q*t^3, (-1)/(-q*t^2)]
      sage: E[omega[1]-omega[2]]   # consistent with before refactoring
      -((t-1)/(-q*t^2+1))*B[(1, 0)] + B[(0, -1)] - ((t-1)/(-q*t^2+1))*B[(0, 1)]
      sage: E.eigenvalues(_)  # not checked
      [1/(q^2*t^3), 1/(q*t), q*t^2]

      sage: E[-omega[2]]
      -((q^2*t^4-q^2*t^3+q*t^3-2*q*t^2+q*t-t+1)/(-q^3*t^4+q^2*t^3+q*t-1))*B[(0, 0)]
      + B[(-1, -1)] - ((t-1)/(-q*t+1))*B[(-1, 1)] + ((t-1)/(q*t-1))*B[(1, -1)]
      - ((q*t^4-q*t^3-t+1)/(-q^3*t^4+q^2*t^3+q*t-1))*B[(1, 1)]
      sage: E.eigenvalues(_)  # not checked   # long time (1s)
      [1/(q^3*t^3), t, q*t]
      sage: E[-omega[2]].map_coefficients(lambda c: c.subs(t=0))     # checking against crystals
      B[(0, 0)] + B[(-1, -1)] + B[(-1, 1)] + B[(1, -1)] + B[(1, 1)]

      sage: E[2*omega[2]]
      -((q^6*t^7-q^6*t^6+q^5*t^6-2*q^5*t^5+q^4*t^5+q^5*t^3-3*q^4*t^4+3*q^4*t^3-q^3*t^4-q^4*t^2+2*q^3*t^2-q^3*t+q^2*t-q^2)/(-q^6*t^7+q^5*t^6+q^4*t^4+q^3*t^4-q^3*t^3-q^2*t^3-q*t+1))*B[(0, 0)]
      - ((q^3*t^2-q^3*t)/(-q^3*t^3+1))*B[(-1, -1)]
      - ((q^3*t^3-2*q^3*t^2+q^3*t)/(-q^4*t^4+q^3*t^3+q*t-1))*B[(-1, 1)]
      - ((q^3*t^3-2*q^3*t^2+q^3*t)/(-q^4*t^4+q^3*t^3+q*t-1))*B[(1, -1)]
      - ((q^4*t^4-q^4*t^3+q^3*t^3-2*q^3*t^2+q^2*t^3+q^3*t-2*q^2*t^2+q^2*t-q*t+q)/(-q^4*t^4+q^3*t^3+q*t-1))*B[(1, 1)]
      + ((q*t-q)/(q*t-1))*B[(2, 0)] + B[(2, 2)] - ((q*t-q)/(-q*t+1))*B[(0, 2)]
      sage: E.eigenvalues(_)  # not checked
      [q^3*t^3, t, (-1)/(-q^2*t^2)]

  [Python]

      >>> from sage.all import *
      >>> K = QQ['q','t'].fraction_field()
      >>> q, t = K.gens()
      >>> KL = RootSystem(["C",Integer(2),Integer(1)]).ambient_space().algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL,q, t, -Integer(1))
      >>> L0 = E.keys()
      >>> omega = L0.fundamental_weights()
      >>> E[Integer(0)*omega[Integer(1)]]
      B[(0, 0)]
      >>> E.eigenvalues(_)  # checked for i=0 with previous calculation
      [1/(q*t^3), t, t]
      >>> E[omega[Integer(1)]]
      B[(1, 0)]
      >>> E.eigenvalues(_)  # not checked
      [t, 1/(q*t^3), t]

      >>> E[-omega[Integer(1)]]           # consistent with before refactoring
      B[(-1, 0)] - ((t-1)/(-q*t+1))*B[(1, 0)] - ((t-1)/(-q*t+1))*B[(0, -1)]
      + ((t-1)/(q*t-1))*B[(0, 1)]
      >>> E.eigenvalues(_)  # not checked
      [(-1)/(-q^2*t^3), q*t, t]
      >>> E[-omega[Integer(1)]+omega[Integer(2)]]  # consistent with before refactoring
      -((t-1)/(-q*t^3+1))*B[(1, 0)] + B[(0, 1)]
      >>> E.eigenvalues(_)  # not checked
      [t, q*t^3, (-1)/(-q*t^2)]
      >>> E[omega[Integer(1)]-omega[Integer(2)]]   # consistent with before refactoring
      -((t-1)/(-q*t^2+1))*B[(1, 0)] + B[(0, -1)] - ((t-1)/(-q*t^2+1))*B[(0, 1)]
      >>> E.eigenvalues(_)  # not checked
      [1/(q^2*t^3), 1/(q*t), q*t^2]

      >>> E[-omega[Integer(2)]]
      -((q^2*t^4-q^2*t^3+q*t^3-2*q*t^2+q*t-t+1)/(-q^3*t^4+q^2*t^3+q*t-1))*B[(0, 0)]
      + B[(-1, -1)] - ((t-1)/(-q*t+1))*B[(-1, 1)] + ((t-1)/(q*t-1))*B[(1, -1)]
      - ((q*t^4-q*t^3-t+1)/(-q^3*t^4+q^2*t^3+q*t-1))*B[(1, 1)]
      >>> E.eigenvalues(_)  # not checked   # long time (1s)
      [1/(q^3*t^3), t, q*t]
      >>> E[-omega[Integer(2)]].map_coefficients(lambda c: c.subs(t=Integer(0)))     # checking against crystals
      B[(0, 0)] + B[(-1, -1)] + B[(-1, 1)] + B[(1, -1)] + B[(1, 1)]

      >>> E[Integer(2)*omega[Integer(2)]]
      -((q^6*t^7-q^6*t^6+q^5*t^6-2*q^5*t^5+q^4*t^5+q^5*t^3-3*q^4*t^4+3*q^4*t^3-q^3*t^4-q^4*t^2+2*q^3*t^2-q^3*t+q^2*t-q^2)/(-q^6*t^7+q^5*t^6+q^4*t^4+q^3*t^4-q^3*t^3-q^2*t^3-q*t+1))*B[(0, 0)]
      - ((q^3*t^2-q^3*t)/(-q^3*t^3+1))*B[(-1, -1)]
      - ((q^3*t^3-2*q^3*t^2+q^3*t)/(-q^4*t^4+q^3*t^3+q*t-1))*B[(-1, 1)]
      - ((q^3*t^3-2*q^3*t^2+q^3*t)/(-q^4*t^4+q^3*t^3+q*t-1))*B[(1, -1)]
      - ((q^4*t^4-q^4*t^3+q^3*t^3-2*q^3*t^2+q^2*t^3+q^3*t-2*q^2*t^2+q^2*t-q*t+q)/(-q^4*t^4+q^3*t^3+q*t-1))*B[(1, 1)]
      + ((q*t-q)/(q*t-1))*B[(2, 0)] + B[(2, 2)] - ((q*t-q)/(-q*t+1))*B[(0, 2)]
      >>> E.eigenvalues(_)  # not checked
      [q^3*t^3, t, (-1)/(-q^2*t^2)]

  The following computations were calculated by hand:

  Sage

      sage: KL0 = KL.classical()
      sage: E11 = KL0.sum_of_terms([[L0([1,1]), 1], [L0([0,0]), (-q*t^2 + q*t)/(1-q*t^3)]])
      sage: E11 == E[omega[2]]
      True
      sage: E.eigenvalues(E11)
      [q*t^3, t, (-1)/(-q*t^2)]

      sage: E1m1 = KL0.sum_of_terms([[L0([1,-1]), 1], [L0([1,1]), (1-t)/(1-q*t^2)],
      ....:                          [L0([0,0]), q*t*(1-t)/(1-q*t^2)]])
      sage: E1m1 == E[2*omega[1]-omega[2]]
      True
      sage: E.eigenvalues(E1m1)
      [1/(q*t), 1/(q^2*t^3), q*t^2]

  Python

      >>> from sage.all import *
      >>> KL0 = KL.classical()
      >>> E11 = KL0.sum_of_terms([[L0([Integer(1),Integer(1)]), Integer(1)], [L0([Integer(0),Integer(0)]), (-q*t**Integer(2) + q*t)/(Integer(1)-q*t**Integer(3))]])
      >>> E11 == E[omega[Integer(2)]]
      True
      >>> E.eigenvalues(E11)
      [q*t^3, t, (-1)/(-q*t^2)]

      >>> E1m1 = KL0.sum_of_terms([[L0([Integer(1),-Integer(1)]), Integer(1)], [L0([Integer(1),Integer(1)]), (Integer(1)-t)/(Integer(1)-q*t**Integer(2))],
      ...                          [L0([Integer(0),Integer(0)]), q*t*(Integer(1)-t)/(Integer(1)-q*t**Integer(2))]])
      >>> E1m1 == E[Integer(2)*omega[Integer(1)]-omega[Integer(2)]]
      True
      >>> E.eigenvalues(E1m1)
      [1/(q*t), 1/(q^2*t^3), q*t^2]

  Now we present an example for a twisted affine root system. The results are eigenvectors:

  Sage

      sage: K = QQ['q','t'].fraction_field()
      sage: q, t = K.gens()
      sage: KL = RootSystem("C2~*").ambient_space().algebra(K)
      sage: E = NonSymmetricMacdonaldPolynomials(KL,q, t, -1)
      sage: omega = E.keys().fundamental_weights()
      sage: E[0*omega[1]]
      B[(0, 0)]
      sage: E.eigenvalues(_)
      [1/(q*t^2), t, t]
      sage: E[omega[1]]
      -((q*t-q)/(-q*t^2+1))*B[(0, 0)] + B[(1, 0)]
      sage: E.eigenvalues(_)
      [q*t^2, 1/(q^2*t^3), t]

      sage: E[-omega[1]]
      -((q*t-q+t-1)/(-q^2*t+1))*B[(0, 0)] + B[(-1, 0)] - ((t-1)/(-q^2*t+1))*B[(1, 0)]
      - ((t-1)/(-q^2*t+1))*B[(0, -1)] + ((t-1)/(q^2*t-1))*B[(0, 1)]
      sage: E.eigenvalues(_)
      [(-1)/(-q^3*t^2), q^2*t, t]
      sage: E[-omega[1]+omega[2]]
      B[(-1/2, 1/2)] - ((t-1)/(-q^2*t^3+1))*B[(1/2, -1/2)]
      - ((q*t^3-q*t^2+t-1)/(-q^2*t^3+1))*B[(1/2, 1/2)]
      sage: E.eigenvalues(_)
      [(-1)/(-q^2*t^2), q^2*t^3, (-1)/(-q*t)]
      sage: E[omega[1]-omega[2]]
      B[(1/2, -1/2)] - ((t-1)/(-q*t^2+1))*B[(1/2, 1/2)]
      sage: E.eigenvalues(_)
      [t, 1/(q^2*t^3), q*t^2]

  [Python]

      >>> from sage.all import *
      >>> K = QQ['q','t'].fraction_field()
      >>> q, t = K.gens()
      >>> KL = RootSystem("C2~*").ambient_space().algebra(K)
      >>> E = NonSymmetricMacdonaldPolynomials(KL,q, t, -Integer(1))
      >>> omega = E.keys().fundamental_weights()
      >>> E[Integer(0)*omega[Integer(1)]]
      B[(0, 0)]
      >>> E.eigenvalues(_)
      [1/(q*t^2), t, t]
      >>> E[omega[Integer(1)]]
      -((q*t-q)/(-q*t^2+1))*B[(0, 0)] + B[(1, 0)]
      >>> E.eigenvalues(_)
      [q*t^2, 1/(q^2*t^3), t]

      >>> E[-omega[Integer(1)]]
      -((q*t-q+t-1)/(-q^2*t+1))*B[(0, 0)] + B[(-1, 0)] - ((t-1)/(-q^2*t+1))*B[(1, 0)]
      - ((t-1)/(-q^2*t+1))*B[(0, -1)] + ((t-1)/(q^2*t-1))*B[(0, 1)]
      >>> E.eigenvalues(_)
      [(-1)/(-q^3*t^2), q^2*t, t]
      >>> E[-omega[Integer(1)]+omega[Integer(2)]]
      B[(-1/2, 1/2)] - ((t-1)/(-q^2*t^3+1))*B[(1/2, -1/2)]
      - ((q*t^3-q*t^2+t-1)/(-q^2*t^3+1))*B[(1/2, 1/2)]
      >>> E.eigenvalues(_)
      [(-1)/(-q^2*t^2), q^2*t^3, (-1)/(-q*t)]
      >>> E[omega[Integer(1)]-omega[Integer(2)]]
      B[(1/2, -1/2)] - ((t-1)/(-q*t^2+1))*B[(1/2, 1/2)]
      >>> E.eigenvalues(_)
      [t, 1/(q^2*t^3), q*t^2]

  Type BC, comparison with calculations with Maple by Bogdan Ion:

  Sage

      sage: K = QQ['q','t'].fraction_field()
      sage: q,t = K.gens()
      sage: def to_SR(x):
      ....:     dim = x.parent().basis().keys().dimension()
      ....:     x_expanded = x.expand([SR.var('x%s'%i) for i in range(1, dim + 1)])
      ....:     return x_expanded.subs(q=SR.var('q'), t=SR.var('t'))
      sage: var('x1,x2,x3')                                                           # needs sage.symbolic
      (x1, x2, x3)

      sage: E = NonSymmetricMacdonaldPolynomials(["BC",2,2], q=q, q1=t^2, q2=-1)
      sage: omega = E.keys().fundamental_weights()
      sage: expected = (t-1)*(t+1)*(2+q^4+2*q^2-2*t^2-2*q^2*t^2-t^4*q^2-q^4*t^4+t^4-3*q^6*t^6-2*q^4*t^6+2*q^6*t^8+2*q^4*t^8+t^10*q^8)*q^4/((q^2*t^3-1)*(q^2*t^3+1)*(t*q-1)*(t*q+1)*(t^2*q^3+1)*(t^2*q^3-1))+(t-1)^2*(t+1)^2*(2*q^2+q^4+2+q^4*t^2)*q^3*x1/((t^2*q^3+1)*(t^2*q^3-1)*(t*q-1)*(t*q+1))+(t-1)^2*(t+1)^2*(q^2+1)*q^5/((t^2*q^3+1)*(t^2*q^3-1)*(t*q-1)*(t*q+1)*x1)+(t-1)^2*(t+1)^2*(q^2+1)*q^4*x2/((t^2*q^3+1)*(t^2*q^3-1)*(t*q-1)*(t*q+1)*x1)+(t-1)^2*(t+1)^2*(2*q^2+q^4+2+q^4*t^2)*q^3*x2/((t^2*q^3+1)*(t^2*q^3-1)*(t*q-1)*(t*q+1))+(t-1)^2*(t+1)^2*(q^2+1)*q^5/((t^2*q^3+1)*(t^2*q^3-1)*(t*q-1)*(t*q+1)*x2)+x1^2*x2^2+(t-1)*(t+1)*(-2*q^2-q^4-2+2*q^2*t^2+t^2+q^6*t^4+q^4*t^4)*q^2*x2*x1/((t^2*q^3+1)*(t^2*q^3-1)*(t*q-1)*(t*q+1))+(t-1)*(t+1)*(q^2+1+q^4*t^2)*q*x2^2*x1/((t^2*q^3-1)*(t^2*q^3+1))+(t-1)*(t+1)*q^3*x1^2/((t^2*q^3-1)*(t^2*q^3+1)*x2)+(t-1)*(t+1)*(q^2+1+q^4*t^2)*q*x2*x1^2/((t^2*q^3-1)*(t^2*q^3+1))+(t-1)*(t+1)*q^6/((t^2*q^3+1)*(t^2*q^3-1)*x1*x2)+(t-1)*(t+1)*(q^2+1+q^4*t^2)*q^2*x1^2/((t^2*q^3-1)*(t^2*q^3+1))+(t-1)*(t+1)*(q^2+1+q^4*t^2)*q^2*x2^2/((t^2*q^3-1)*(t^2*q^3+1))+(t-1)*(t+1)*q^3*x2^2/((t^2*q^3-1)*(t^2*q^3+1)*x1)+(t-1)^2*(t+1)^2*(q^2+1)*q^4*x1/((t^2*q^3+1)*(t^2*q^3-1)*(t*q-1)*(t*q+1)*x2)  # needs sage.symbolic
      sage: to_SR(E[2*omega[2]]) - expected   # long time (3.5s)                      # needs sage.symbolic
      0

      sage: E = NonSymmetricMacdonaldPolynomials(["BC",3,2], q=q, q1=t^2, q2=-1)
      sage: omega=E.keys().fundamental_weights()
      sage: mu = -3*omega[1] + 3*omega[2] - omega[3]; mu
      (-1, 2, -1)
      sage: expected = (t-1)^2*(t+1)^2*(3*q^2+q^4+1+t^2*q^4+q^2*t^2-3*t^4*q^2-5*t^6*q^4+2*t^8*q^4-4*t^8*q^6-q^8*t^10+2*t^10*q^6-2*q^8*t^12+t^14*q^8-t^14*q^10+q^10*t^16+q^8*t^16+q^10*t^18+t^18*q^12)*x2*x1/((q^3*t^5+1)*(q^3*t^5-1)*(t*q-1)*(t*q+1)*(t^3*q^2+1)*(t^3*q^2-1)*(t^2*q-1)*(t^2*q+1))+(t-1)^2*(t+1)^2*(q^2*t^6+2*t^6*q^4-q^4*t^4+t^4*q^2-q^2*t^2+t^2-2-q^2)*q^2*x1/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x2)+(t-1)^2*(t+1)^2*(-q^2-1+t^4*q^2-q^4*t^4+2*t^6*q^4)*x1^2/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1))+(t+1)*(t-1)*x2^2*x3/((t*q-1)*(t*q+1)*x1)+(t-1)^2*(t+1)^2*(3*q^2+q^4+2+t^2*q^4+2*q^2*t^2-4*t^4*q^2+q^4*t^4-6*t^6*q^4+t^8*q^4-4*t^8*q^6-q^8*t^10+t^10*q^6-3*q^8*t^12-2*t^14*q^10+2*t^14*q^8+2*q^10*t^16+q^8*t^16+t^18*q^12+2*q^10*t^18)*q*x2/((q^3*t^5+1)*(q^3*t^5-1)*(t*q-1)*(t*q+1)*(t^3*q^2+1)*(t^3*q^2-1)*(t^2*q-1)*(t^2*q+1))+(t-1)^2*(t+1)^2*(1+q^4+2*q^2+t^2*q^4-3*t^4*q^2+q^2*t^6-5*t^6*q^4+3*t^8*q^4-4*t^8*q^6+2*t^10*q^6-q^8*t^12-t^14*q^10+t^14*q^8+q^10*t^16+t^18*q^12)*x3*x1/((q^3*t^5+1)*(q^3*t^5-1)*(t*q-1)*(t*q+1)*(t^3*q^2+1)*(t^3*q^2-1)*(t^2*q-1)*(t^2*q+1))+(t-1)^2*(t+1)^2*(2*q^2+1+q^4+t^2*q^4-t^2+q^2*t^2-4*t^4*q^2+q^4*t^4+q^2*t^6-5*t^6*q^4+3*t^8*q^4-4*t^8*q^6+2*t^10*q^6+q^6*t^12-2*q^8*t^12-2*t^14*q^10+2*t^14*q^8+q^10*t^16+t^18*q^12)*q*x3/((q^3*t^5+1)*(q^3*t^5-1)*(t*q-1)*(t*q+1)*(t^3*q^2+1)*(t^3*q^2-1)*(t^2*q-1)*(t^2*q+1))+(t-1)^2*(t+1)^2*(1+t^2+t^4*q^2)*q*x3*x2^2/((t*q-1)*(t*q+1)*(t^3*q^2+1)*(t^3*q^2-1))+(t-1)^2*(t+1)^2*(-q^2-2-q^2*t^2+t^4-q^4*t^4-t^4*q^2+3*q^2*t^6-t^6*q^4-t^8*q^6+t^8*q^4+t^10*q^4+2*q^6*t^12-q^8*t^12+t^14*q^8)*q*x3*x2*x1/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1))+(t-1)*(t+1)*x1^2/((q^3*t^5-1)*(q^3*t^5+1)*x3*x2)+(t-1)*(t+1)*(-q^2-1+t^4*q^2-q^4*t^4+2*t^6*q^4)*x2^2/((t*q-1)*(t*q+1)*(t^3*q^2+1)*(t^3*q^2-1))+(t-1)*(t+1)*(t^3*q-1)*(t^3*q+1)*x3*x2^2*x1/((t*q-1)*(t*q+1)*(t^3*q^2+1)*(t^3*q^2-1))+(t-1)^2*(t+1)^2*(q^2+1)*q*x1/((t*q+1)*(t*q-1)*(q^3*t^5+1)*(q^3*t^5-1)*x3*x2)+(t-1)^2*(t+1)^2*(t^3*q-1)*(t^3*q+1)*x3*x2*x1^2/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1))+(t-1)^2*(t+1)^2*q^3*x3/((t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x1*x2)+(t-1)*(t+1)*(-1-q^2+q^2*t^2+t^10*q^6)*q*x2/((t*q+1)*(t*q-1)*(q^3*t^5+1)*(q^3*t^5-1)*x3*x1)+x2^2/(x1*x3)+(t-1)*(t+1)*q*x2^2/((t*q-1)*(t*q+1)*x3)+(t-1)^3*(t+1)^3*(1+t^2+t^4*q^2)*q*x2*x1^2/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1))+(t-1)^2*(t+1)^2*q*x1^2/((t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x3)+(t-1)^2*(t+1)^2*(q^2*t^6+2*t^6*q^4-q^4*t^4+t^4*q^2-q^2*t^2+t^2-2-q^2)*q^3/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x2)+(t-1)*(t+1)*(q^2+2-t^2+q^4*t^4-t^4*q^2-3*t^6*q^4+t^8*q^4-2*t^10*q^6-q^8*t^12+q^6*t^12+q^8*t^16+q^10*t^16)*q^2*x2/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x1)+(t-1)^2*(t+1)^2*(q^2+1)*q^2/((t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x3*x2)+(t-1)*(t+1)*(1+q^4+2*q^2-2*q^2*t^2+t^4*q^6-q^4*t^4-3*q^6*t^6-t^6*q^4+2*t^8*q^6-t^10*q^6-q^8*t^10-t^14*q^10+t^14*q^8+2*q^10*t^16)*x2/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x3)+(t-1)^2*(t+1)^2*(-q^2-2-q^2*t^2-q^4*t^4+2*t^6*q^4+t^10*q^6+q^8*t^12+t^14*q^8)*q^3/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x1)+(t-1)^2*(t+1)^2*(-1-q^2-q^2*t^2+t^2+t^4*q^2-q^4*t^4+2*t^6*q^4)*q^2*x3/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x2)+(t-1)*(t+1)*q*x2^2/((t*q-1)*(t*q+1)*x1)+(t-1)^2*(t+1)^2*(1+t^2+t^4*q^2)*q*x2^2*x1/((t*q-1)*(t*q+1)*(t^3*q^2+1)*(t^3*q^2-1))+(t-1)^2*(t+1)^2*q*x1^2/((t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x2)+(t-1)^2*(t+1)^2*(-1-q^4-2*q^2-t^2*q^4-q^2*t^2+t^4*q^2-t^4*q^6-2*q^4*t^4+3*t^6*q^4-q^6*t^6-t^8*q^8+t^8*q^6+2*t^10*q^6-q^10*t^12+3*q^8*t^12+2*t^14*q^10)*x3*x2/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1))+(t-1)*(t+1)*(q^2+1-t^2+q^4*t^4-t^4*q^2+q^2*t^6-3*t^6*q^4+t^8*q^4-t^10*q^6+q^6*t^12-q^8*t^12+q^10*t^16)*q^2*x3/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x1)+(t-1)*(t+1)*(-1-q^2+q^2*t^2+t^10*q^6)*q^2/((t*q-1)*(t*q+1)*(q^3*t^5+1)*(q^3*t^5-1)*x1*x3)+(t-1)*(t+1)*(1+q^4+2*q^2-3*q^2*t^2+t^4*q^6-q^4*t^4-3*q^6*t^6-t^6*q^4+t^8*q^4+2*t^8*q^6-t^10*q^6+t^14*q^8-t^14*q^10+q^10*t^16)*x1/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x3)+(t-1)^2*(t+1)^2*(3*q^2+q^4+2+q^2*t^2-t^2+t^2*q^4-6*t^4*q^2+q^4*t^4-7*t^6*q^4+q^2*t^6+3*t^8*q^4-4*t^8*q^6+t^10*q^4+3*t^10*q^6-q^8*t^12-t^14*q^10+t^14*q^8+q^8*t^16+q^10*t^18)*q*x1/((q^3*t^5+1)*(q^3*t^5-1)*(t*q-1)*(t*q+1)*(t^3*q^2+1)*(t^3*q^2-1)*(t^2*q-1)*(t^2*q+1))+(t-1)^2*(t+1)^2*(-q^2-2-q^2*t^2-q^4*t^4+2*t^6*q^4+t^10*q^6+q^6*t^12+t^14*q^8)*q*x2*x1/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x3)+(t+1)*(t-1)*x2^2*x1/((t*q-1)*(t*q+1)*x3)+(t-1)^3*(t+1)^3*(1+t^2+t^4*q^2)*q*x3*x1^2/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1))+(t-1)*(t+1)*q^3/((q^3*t^5+1)*(q^3*t^5-1)*x1*x2*x3)+(t-1)^2*(t+1)^2*(3+3*q^2+q^4+2*q^2*t^2-t^2+t^2*q^4-6*t^4*q^2+q^4*t^4-8*t^6*q^4+q^2*t^6+2*t^8*q^4-4*t^8*q^6+t^10*q^4+2*t^10*q^6-2*q^8*t^12-t^14*q^10+t^14*q^8+q^8*t^16+q^10*t^16+2*q^10*t^18)*q^2/((q^3*t^5+1)*(q^3*t^5-1)*(t*q-1)*(t*q+1)*(t^3*q^2+1)*(t^3*q^2-1)*(t^2*q-1)*(t^2*q+1))+(t-1)^2*(t+1)^2*(-q^4-2*q^2-1-t^2*q^4-t^4*q^6+2*q^6*t^6+t^6*q^4+t^10*q^6+q^8*t^12+t^14*q^10)*q/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x3)+(t-1)^2*(t+1)^2*(-1-q^2-q^2*t^2+t^2+t^4*q^2-q^4*t^4+2*t^6*q^4)*q*x3*x1/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x2)+(t-1)^2*(t+1)^2*x2*x1^2/((t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x3)+(t-1)^2*(t+1)^2*x3*x1^2/((t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x2)+(t-1)^2*(t+1)^2*q^4/((t*q+1)*(t*q-1)*(q^3*t^5+1)*(q^3*t^5-1)*x1*x2)+(t-1)^2*(t+1)^2*(-q^2-1-q^2*t^2-q^4*t^4+t^6*q^4+t^10*q^6+q^8*t^12+t^14*q^10)*q*x3*x2/((t^3*q^2-1)*(t^3*q^2+1)*(t*q+1)*(t*q-1)*(q^3*t^5-1)*(q^3*t^5+1)*x1)  # needs sage.symbolic
      sage: to_SR(E[mu]) - expected           # long time (20s)                       # needs sage.symbolic
      0

      sage: E = NonSymmetricMacdonaldPolynomials(["BC",1,2], q=q, q1=t^2, q2=-1)
      sage: omega = E.keys().fundamental_weights()
      sage: mu = -4*omega[1]; mu
      (-4)
      sage: expected = (t-1)*(t+1)*(-1+q^2*t^2-q^2-3*q^10-7*q^26*t^8+5*t^2*q^6-q^16-3*q^4+4*t^10*q^30-4*t^6*q^22-10*q^20*t^6+2*q^32*t^10-3*q^6-4*q^8+q^34*t^10-4*t^8*q^24-2*q^12-q^14+2*q^22*t^10+4*q^26*t^10+4*q^28*t^10+t^6*q^30-2*q^32*t^8-2*t^8*q^22+2*q^24*t^10-q^20*t^2-2*t^6*q^12+t^8*q^14+2*t^4*q^24-4*t^8*q^30+2*t^8*q^20-9*t^6*q^16+3*q^26*t^6+q^28*t^6+3*t^2*q^4+2*q^18*t^8-6*t^6*q^14+4*t^4*q^22-2*q^24*t^6+3*t^2*q^12+7*t^4*q^20-t^2*q^16+11*q^18*t^4-2*t^2*q^18+9*q^16*t^4-t^4*q^6+6*q^8*t^2+5*q^10*t^2-6*q^28*t^8+q^12*t^4+8*t^4*q^14-10*t^6*q^18-q^4*t^4+q^16*t^8-2*t^4*q^8)/((t*q^4-1)*(t*q^4+1)*(q^7*t^2-1)*(q^7*t^2+1)*(t*q^3-1)*(t*q^3+1)*(q^5*t^2+1)*(q^5*t^2-1))+(q^2+1)*(q^4+1)*(t-1)*(t+1)*(-1+q^2*t^2-q^2+t^2*q^6-q^4+t^6*q^22+3*q^10*t^4+t^2-q^8-2*t^8*q^24+q^22*t^10+q^26*t^10-2*t^8*q^22+q^24*t^10-4*t^6*q^12-2*t^8*q^20-3*t^6*q^16+2*t^2*q^4-t^6*q^10-2*t^6*q^14+t^8*q^12-t^2*q^12+2*q^16*t^4+q^8*t^2-q^10*t^2+3*q^12*t^4+2*t^4*q^14+t^6*q^18-2*q^4*t^4+q^16*t^8+q^20*t^10)*q*x1/((t*q^4-1)*(t*q^4+1)*(q^7*t^2-1)*(q^7*t^2+1)*(t*q^3-1)*(t*q^3+1)*(q^5*t^2+1)*(q^5*t^2-1))+(q^2+1)*(q^4+1)*(t-1)*(t+1)*(1+q^8+q^4+q^2-q^8*t^2-2*t^2*q^4-t^2*q^6+t^2*q^12-t^2+t^4*q^6-2*q^16*t^4-t^4*q^14-2*q^12*t^4+t^6*q^12+t^6*q^16+t^6*q^18+t^6*q^14)*q/((t*q^4-1)*(t*q^4+1)*(q^7*t^2-1)*(q^7*t^2+1)*(t*q^3-1)*(t*q^3+1)*x1)+(t-1)*(t+1)*(-1-q^2-q^6-q^4-q^8+t^2*q^4-t^2*q^14+t^2*q^6-q^10*t^2+q^8*t^2-t^2*q^12+q^12*t^4+q^10*t^4+q^16*t^4+2*t^4*q^14)*(q^4+1)/((q^7*t^2+1)*(q^7*t^2-1)*(t*q^4-1)*(t*q^4+1)*x1^2)+(t-1)*(t+1)*(q^4+1)*(q^2+1)*q/((t*q^4-1)*(t*q^4+1)*x1^3)+(q^4+1)*(t-1)*(t+1)*(1+q^6+q^8+q^2+q^4-q^2*t^2-3*t^2*q^4+q^10*t^2+t^2*q^12-2*t^2*q^6-q^8*t^2-2*q^16*t^4+q^4*t^4+t^4*q^6-q^10*t^4-2*q^12*t^4-2*t^4*q^14+t^6*q^12+t^6*q^18+2*t^6*q^16+t^6*q^14)*x1^2/((t*q^4-1)*(t*q^4+1)*(q^7*t^2-1)*(q^7*t^2+1)*(t*q^3-1)*(t*q^3+1))+(t-1)*(t+1)*(-1-t^2*q^6+t^2+t^4*q^8)*(q^4+1)*(q^2+1)*q*x1^3/((q^7*t^2+1)*(q^7*t^2-1)*(t*q^4-1)*(t*q^4+1))+1/x1^4+(t-1)*(t+1)*x1^4/((t*q^4-1)*(t*q^4+1))  # needs sage.symbolic
      sage: to_SR(E[mu]) - expected                                                   # needs sage.symbolic
      0

  Python

      >>> from sage.all import *
      >>> K = QQ['q','t'].fraction_field()
      >>> q,t = K.gens()
      >>> def to_SR(x):
      ...     dim = x.parent().basis().keys().dimension()
      ...     x_expanded = x.expand([SR.var('x%s'%i) for i in range(Integer(1), dim + Integer(1))])
      ...     return x_expanded.subs(q=SR.var('q'), t=SR.var('t'))
      >>> var('x1,x2,x3')                                                           # needs sage.symbolic
      (x1, x2, x3)

      >>> E = NonSymmetricMacdonaldPolynomials(["BC",Integer(2),Integer(2)], q=q, q1=t**Integer(2), q2=-Integer(1))
      >>> omega = E.keys().fundamental_weights()
      >>> expected = (t-Integer(1))*(t+Integer(1))*(Integer(2)+q**Integer(4)+Integer(2)*q**Integer(2)-Integer(2)*t**Integer(2)-Integer(2)*q**Integer(2)*t**Integer(2)-t**Integer(4)*q**Integer(2)-q**Integer(4)*t**Integer(4)+t**Integer(4)-Integer(3)*q**Integer(6)*t**Integer(6)-Integer(2)*q**Integer(4)*t**Integer(6)+Integer(2)*q**Integer(6)*t**Integer(8)+Integer(2)*q**Integer(4)*t**Integer(8)+t**Integer(10)*q**Integer(8))*q**Integer(4)/((q**Integer(2)*t**Integer(3)-Integer(1))*(q**Integer(2)*t**Integer(3)+Integer(1))*(t*q-Integer(1))*(t*q+Integer(1))*(t**Integer(2)*q**Integer(3)+Integer(1))*(t**Integer(2)*q**Integer(3)-Integer(1)))+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(Integer(2)*q**Integer(2)+q**Integer(4)+Integer(2)+q**Integer(4)*t**Integer(2))*q**Integer(3)*x1/((t**Integer(2)*q**Integer(3)+Integer(1))*(t**Integer(2)*q**Integer(3)-Integer(1))*(t*q-Integer(1))*(t*q+Integer(1)))+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(q**Integer(2)+Integer(1))*q**Integer(5)/((t**Integer(2)*q**Integer(3)+Integer(1))*(t**Integer(2)*q**Integer(3)-Integer(1))*(t*q-Integer(1))*(t*q+Integer(1))*x1)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(q**Integer(2)+Integer(1))*q**Integer(4)*x2/((t**Integer(2)*q**Integer(3)+Integer(1))*(t**Integer(2)*q**Integer(3)-Integer(1))*(t*q-Integer(1))*(t*q+Integer(1))*x1)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(Integer(2)*q**Integer(2)+q**Integer(4)+Integer(2)+q**Integer(4)*t**Integer(2))*q**Integer(3)*x2/((t**Integer(2)*q**Integer(3)+Integer(1))*(t**Integer(2)*q**Integer(3)-Integer(1))*(t*q-Integer(1))*(t*q+Integer(1)))+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(q**Integer(2)+Integer(1))*q**Integer(5)/((t**Integer(2)*q**Integer(3)+Integer(1))*(t**Integer(2)*q**Integer(3)-Integer(1))*(t*q-Integer(1))*(t*q+Integer(1))*x2)+x1**Integer(2)*x2**Integer(2)+(t-Integer(1))*(t+Integer(1))*(-Integer(2)*q**Integer(2)-q**Integer(4)-Integer(2)+Integer(2)*q**Integer(2)*t**Integer(2)+t**Integer(2)+q**Integer(6)*t**Integer(4)+q**Integer(4)*t**Integer(4))*q**Integer(2)*x2*x1/((t**Integer(2)*q**Integer(3)+Integer(1))*(t**Integer(2)*q**Integer(3)-Integer(1))*(t*q-Integer(1))*(t*q+Integer(1)))+(t-Integer(1))*(t+Integer(1))*(q**Integer(2)+Integer(1)+q**Integer(4)*t**Integer(2))*q*x2**Integer(2)*x1/((t**Integer(2)*q**Integer(3)-Integer(1))*(t**Integer(2)*q**Integer(3)+Integer(1)))+(t-Integer(1))*(t+Integer(1))*q**Integer(3)*x1**Integer(2)/((t**Integer(2)*q**Integer(3)-Integer(1))*(t**Integer(2)*q**Integer(3)+Integer(1))*x2)+(t-Integer(1))*(t+Integer(1))*(q**Integer(2)+Integer(1)+q**Integer(4)*t**Integer(2))*q*x2*x1**Integer(2)/((t**Integer(2)*q**Integer(3)-Integer(1))*(t**Integer(2)*q**Integer(3)+Integer(1)))+(t-Integer(1))*(t+Integer(1))*q**Integer(6)/((t**Integer(2)*q**Integer(3)+Integer(1))*(t**Integer(2)*q**Integer(3)-Integer(1))*x1*x2)+(t-Integer(1))*(t+Integer(1))*(q**Integer(2)+Integer(1)+q**Integer(4)*t**Integer(2))*q**Integer(2)*x1**Integer(2)/((t**Integer(2)*q**Integer(3)-Integer(1))*(t**Integer(2)*q**Integer(3)+Integer(1)))+(t-Integer(1))*(t+Integer(1))*(q**Integer(2)+Integer(1)+q**Integer(4)*t**Integer(2))*q**Integer(2)*x2**Integer(2)/((t**Integer(2)*q**Integer(3)-Integer(1))*(t**Integer(2)*q**Integer(3)+Integer(1)))+(t-Integer(1))*(t+Integer(1))*q**Integer(3)*x2**Integer(2)/((t**Integer(2)*q**Integer(3)-Integer(1))*(t**Integer(2)*q**Integer(3)+Integer(1))*x1)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(q**Integer(2)+Integer(1))*q**Integer(4)*x1/((t**Integer(2)*q**Integer(3)+Integer(1))*(t**Integer(2)*q**Integer(3)-Integer(1))*(t*q-Integer(1))*(t*q+Integer(1))*x2)  # needs sage.symbolic
      >>> to_SR(E[Integer(2)*omega[Integer(2)]]) - expected   # long time (3.5s)                      # needs sage.symbolic
      0

      >>> E = NonSymmetricMacdonaldPolynomials(["BC",Integer(3),Integer(2)], q=q, q1=t**Integer(2), q2=-Integer(1))
      >>> omega=E.keys().fundamental_weights()
      >>> mu = -Integer(3)*omega[Integer(1)] + Integer(3)*omega[Integer(2)] - omega[Integer(3)]; mu
      (-1, 2, -1)
      >>> expected = (t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(Integer(3)*q**Integer(2)+q**Integer(4)+Integer(1)+t**Integer(2)*q**Integer(4)+q**Integer(2)*t**Integer(2)-Integer(3)*t**Integer(4)*q**Integer(2)-Integer(5)*t**Integer(6)*q**Integer(4)+Integer(2)*t**Integer(8)*q**Integer(4)-Integer(4)*t**Integer(8)*q**Integer(6)-q**Integer(8)*t**Integer(10)+Integer(2)*t**Integer(10)*q**Integer(6)-Integer(2)*q**Integer(8)*t**Integer(12)+t**Integer(14)*q**Integer(8)-t**Integer(14)*q**Integer(10)+q**Integer(10)*t**Integer(16)+q**Integer(8)*t**Integer(16)+q**Integer(10)*t**Integer(18)+t**Integer(18)*q**Integer(12))*x2*x1/((q**Integer(3)*t**Integer(5)+Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(t*q-Integer(1))*(t*q+Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(2)*q-Integer(1))*(t**Integer(2)*q+Integer(1)))+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(q**Integer(2)*t**Integer(6)+Integer(2)*t**Integer(6)*q**Integer(4)-q**Integer(4)*t**Integer(4)+t**Integer(4)*q**Integer(2)-q**Integer(2)*t**Integer(2)+t**Integer(2)-Integer(2)-q**Integer(2))*q**Integer(2)*x1/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x2)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(-q**Integer(2)-Integer(1)+t**Integer(4)*q**Integer(2)-q**Integer(4)*t**Integer(4)+Integer(2)*t**Integer(6)*q**Integer(4))*x1**Integer(2)/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1)))+(t+Integer(1))*(t-Integer(1))*x2**Integer(2)*x3/((t*q-Integer(1))*(t*q+Integer(1))*x1)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(Integer(3)*q**Integer(2)+q**Integer(4)+Integer(2)+t**Integer(2)*q**Integer(4)+Integer(2)*q**Integer(2)*t**Integer(2)-Integer(4)*t**Integer(4)*q**Integer(2)+q**Integer(4)*t**Integer(4)-Integer(6)*t**Integer(6)*q**Integer(4)+t**Integer(8)*q**Integer(4)-Integer(4)*t**Integer(8)*q**Integer(6)-q**Integer(8)*t**Integer(10)+t**Integer(10)*q**Integer(6)-Integer(3)*q**Integer(8)*t**Integer(12)-Integer(2)*t**Integer(14)*q**Integer(10)+Integer(2)*t**Integer(14)*q**Integer(8)+Integer(2)*q**Integer(10)*t**Integer(16)+q**Integer(8)*t**Integer(16)+t**Integer(18)*q**Integer(12)+Integer(2)*q**Integer(10)*t**Integer(18))*q*x2/((q**Integer(3)*t**Integer(5)+Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(t*q-Integer(1))*(t*q+Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(2)*q-Integer(1))*(t**Integer(2)*q+Integer(1)))+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(Integer(1)+q**Integer(4)+Integer(2)*q**Integer(2)+t**Integer(2)*q**Integer(4)-Integer(3)*t**Integer(4)*q**Integer(2)+q**Integer(2)*t**Integer(6)-Integer(5)*t**Integer(6)*q**Integer(4)+Integer(3)*t**Integer(8)*q**Integer(4)-Integer(4)*t**Integer(8)*q**Integer(6)+Integer(2)*t**Integer(10)*q**Integer(6)-q**Integer(8)*t**Integer(12)-t**Integer(14)*q**Integer(10)+t**Integer(14)*q**Integer(8)+q**Integer(10)*t**Integer(16)+t**Integer(18)*q**Integer(12))*x3*x1/((q**Integer(3)*t**Integer(5)+Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(t*q-Integer(1))*(t*q+Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(2)*q-Integer(1))*(t**Integer(2)*q+Integer(1)))+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(Integer(2)*q**Integer(2)+Integer(1)+q**Integer(4)+t**Integer(2)*q**Integer(4)-t**Integer(2)+q**Integer(2)*t**Integer(2)-Integer(4)*t**Integer(4)*q**Integer(2)+q**Integer(4)*t**Integer(4)+q**Integer(2)*t**Integer(6)-Integer(5)*t**Integer(6)*q**Integer(4)+Integer(3)*t**Integer(8)*q**Integer(4)-Integer(4)*t**Integer(8)*q**Integer(6)+Integer(2)*t**Integer(10)*q**Integer(6)+q**Integer(6)*t**Integer(12)-Integer(2)*q**Integer(8)*t**Integer(12)-Integer(2)*t**Integer(14)*q**Integer(10)+Integer(2)*t**Integer(14)*q**Integer(8)+q**Integer(10)*t**Integer(16)+t**Integer(18)*q**Integer(12))*q*x3/((q**Integer(3)*t**Integer(5)+Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(t*q-Integer(1))*(t*q+Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(2)*q-Integer(1))*(t**Integer(2)*q+Integer(1)))+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(Integer(1)+t**Integer(2)+t**Integer(4)*q**Integer(2))*q*x3*x2**Integer(2)/((t*q-Integer(1))*(t*q+Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t**Integer(3)*q**Integer(2)-Integer(1)))+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(-q**Integer(2)-Integer(2)-q**Integer(2)*t**Integer(2)+t**Integer(4)-q**Integer(4)*t**Integer(4)-t**Integer(4)*q**Integer(2)+Integer(3)*q**Integer(2)*t**Integer(6)-t**Integer(6)*q**Integer(4)-t**Integer(8)*q**Integer(6)+t**Integer(8)*q**Integer(4)+t**Integer(10)*q**Integer(4)+Integer(2)*q**Integer(6)*t**Integer(12)-q**Integer(8)*t**Integer(12)+t**Integer(14)*q**Integer(8))*q*x3*x2*x1/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1)))+(t-Integer(1))*(t+Integer(1))*x1**Integer(2)/((q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x3*x2)+(t-Integer(1))*(t+Integer(1))*(-q**Integer(2)-Integer(1)+t**Integer(4)*q**Integer(2)-q**Integer(4)*t**Integer(4)+Integer(2)*t**Integer(6)*q**Integer(4))*x2**Integer(2)/((t*q-Integer(1))*(t*q+Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t**Integer(3)*q**Integer(2)-Integer(1)))+(t-Integer(1))*(t+Integer(1))*(t**Integer(3)*q-Integer(1))*(t**Integer(3)*q+Integer(1))*x3*x2**Integer(2)*x1/((t*q-Integer(1))*(t*q+Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t**Integer(3)*q**Integer(2)-Integer(1)))+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(q**Integer(2)+Integer(1))*q*x1/((t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*x3*x2)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(t**Integer(3)*q-Integer(1))*(t**Integer(3)*q+Integer(1))*x3*x2*x1**Integer(2)/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1)))+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*q**Integer(3)*x3/((t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x1*x2)+(t-Integer(1))*(t+Integer(1))*(-Integer(1)-q**Integer(2)+q**Integer(2)*t**Integer(2)+t**Integer(10)*q**Integer(6))*q*x2/((t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*x3*x1)+x2**Integer(2)/(x1*x3)+(t-Integer(1))*(t+Integer(1))*q*x2**Integer(2)/((t*q-Integer(1))*(t*q+Integer(1))*x3)+(t-Integer(1))**Integer(3)*(t+Integer(1))**Integer(3)*(Integer(1)+t**Integer(2)+t**Integer(4)*q**Integer(2))*q*x2*x1**Integer(2)/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1)))+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*q*x1**Integer(2)/((t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x3)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(q**Integer(2)*t**Integer(6)+Integer(2)*t**Integer(6)*q**Integer(4)-q**Integer(4)*t**Integer(4)+t**Integer(4)*q**Integer(2)-q**Integer(2)*t**Integer(2)+t**Integer(2)-Integer(2)-q**Integer(2))*q**Integer(3)/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x2)+(t-Integer(1))*(t+Integer(1))*(q**Integer(2)+Integer(2)-t**Integer(2)+q**Integer(4)*t**Integer(4)-t**Integer(4)*q**Integer(2)-Integer(3)*t**Integer(6)*q**Integer(4)+t**Integer(8)*q**Integer(4)-Integer(2)*t**Integer(10)*q**Integer(6)-q**Integer(8)*t**Integer(12)+q**Integer(6)*t**Integer(12)+q**Integer(8)*t**Integer(16)+q**Integer(10)*t**Integer(16))*q**Integer(2)*x2/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x1)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(q**Integer(2)+Integer(1))*q**Integer(2)/((t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x3*x2)+(t-Integer(1))*(t+Integer(1))*(Integer(1)+q**Integer(4)+Integer(2)*q**Integer(2)-Integer(2)*q**Integer(2)*t**Integer(2)+t**Integer(4)*q**Integer(6)-q**Integer(4)*t**Integer(4)-Integer(3)*q**Integer(6)*t**Integer(6)-t**Integer(6)*q**Integer(4)+Integer(2)*t**Integer(8)*q**Integer(6)-t**Integer(10)*q**Integer(6)-q**Integer(8)*t**Integer(10)-t**Integer(14)*q**Integer(10)+t**Integer(14)*q**Integer(8)+Integer(2)*q**Integer(10)*t**Integer(16))*x2/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x3)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(-q**Integer(2)-Integer(2)-q**Integer(2)*t**Integer(2)-q**Integer(4)*t**Integer(4)+Integer(2)*t**Integer(6)*q**Integer(4)+t**Integer(10)*q**Integer(6)+q**Integer(8)*t**Integer(12)+t**Integer(14)*q**Integer(8))*q**Integer(3)/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x1)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(-Integer(1)-q**Integer(2)-q**Integer(2)*t**Integer(2)+t**Integer(2)+t**Integer(4)*q**Integer(2)-q**Integer(4)*t**Integer(4)+Integer(2)*t**Integer(6)*q**Integer(4))*q**Integer(2)*x3/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x2)+(t-Integer(1))*(t+Integer(1))*q*x2**Integer(2)/((t*q-Integer(1))*(t*q+Integer(1))*x1)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(Integer(1)+t**Integer(2)+t**Integer(4)*q**Integer(2))*q*x2**Integer(2)*x1/((t*q-Integer(1))*(t*q+Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t**Integer(3)*q**Integer(2)-Integer(1)))+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*q*x1**Integer(2)/((t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x2)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(-Integer(1)-q**Integer(4)-Integer(2)*q**Integer(2)-t**Integer(2)*q**Integer(4)-q**Integer(2)*t**Integer(2)+t**Integer(4)*q**Integer(2)-t**Integer(4)*q**Integer(6)-Integer(2)*q**Integer(4)*t**Integer(4)+Integer(3)*t**Integer(6)*q**Integer(4)-q**Integer(6)*t**Integer(6)-t**Integer(8)*q**Integer(8)+t**Integer(8)*q**Integer(6)+Integer(2)*t**Integer(10)*q**Integer(6)-q**Integer(10)*t**Integer(12)+Integer(3)*q**Integer(8)*t**Integer(12)+Integer(2)*t**Integer(14)*q**Integer(10))*x3*x2/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1)))+(t-Integer(1))*(t+Integer(1))*(q**Integer(2)+Integer(1)-t**Integer(2)+q**Integer(4)*t**Integer(4)-t**Integer(4)*q**Integer(2)+q**Integer(2)*t**Integer(6)-Integer(3)*t**Integer(6)*q**Integer(4)+t**Integer(8)*q**Integer(4)-t**Integer(10)*q**Integer(6)+q**Integer(6)*t**Integer(12)-q**Integer(8)*t**Integer(12)+q**Integer(10)*t**Integer(16))*q**Integer(2)*x3/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x1)+(t-Integer(1))*(t+Integer(1))*(-Integer(1)-q**Integer(2)+q**Integer(2)*t**Integer(2)+t**Integer(10)*q**Integer(6))*q**Integer(2)/((t*q-Integer(1))*(t*q+Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*x1*x3)+(t-Integer(1))*(t+Integer(1))*(Integer(1)+q**Integer(4)+Integer(2)*q**Integer(2)-Integer(3)*q**Integer(2)*t**Integer(2)+t**Integer(4)*q**Integer(6)-q**Integer(4)*t**Integer(4)-Integer(3)*q**Integer(6)*t**Integer(6)-t**Integer(6)*q**Integer(4)+t**Integer(8)*q**Integer(4)+Integer(2)*t**Integer(8)*q**Integer(6)-t**Integer(10)*q**Integer(6)+t**Integer(14)*q**Integer(8)-t**Integer(14)*q**Integer(10)+q**Integer(10)*t**Integer(16))*x1/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x3)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(Integer(3)*q**Integer(2)+q**Integer(4)+Integer(2)+q**Integer(2)*t**Integer(2)-t**Integer(2)+t**Integer(2)*q**Integer(4)-Integer(6)*t**Integer(4)*q**Integer(2)+q**Integer(4)*t**Integer(4)-Integer(7)*t**Integer(6)*q**Integer(4)+q**Integer(2)*t**Integer(6)+Integer(3)*t**Integer(8)*q**Integer(4)-Integer(4)*t**Integer(8)*q**Integer(6)+t**Integer(10)*q**Integer(4)+Integer(3)*t**Integer(10)*q**Integer(6)-q**Integer(8)*t**Integer(12)-t**Integer(14)*q**Integer(10)+t**Integer(14)*q**Integer(8)+q**Integer(8)*t**Integer(16)+q**Integer(10)*t**Integer(18))*q*x1/((q**Integer(3)*t**Integer(5)+Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(t*q-Integer(1))*(t*q+Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(2)*q-Integer(1))*(t**Integer(2)*q+Integer(1)))+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(-q**Integer(2)-Integer(2)-q**Integer(2)*t**Integer(2)-q**Integer(4)*t**Integer(4)+Integer(2)*t**Integer(6)*q**Integer(4)+t**Integer(10)*q**Integer(6)+q**Integer(6)*t**Integer(12)+t**Integer(14)*q**Integer(8))*q*x2*x1/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x3)+(t+Integer(1))*(t-Integer(1))*x2**Integer(2)*x1/((t*q-Integer(1))*(t*q+Integer(1))*x3)+(t-Integer(1))**Integer(3)*(t+Integer(1))**Integer(3)*(Integer(1)+t**Integer(2)+t**Integer(4)*q**Integer(2))*q*x3*x1**Integer(2)/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1)))+(t-Integer(1))*(t+Integer(1))*q**Integer(3)/((q**Integer(3)*t**Integer(5)+Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*x1*x2*x3)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(Integer(3)+Integer(3)*q**Integer(2)+q**Integer(4)+Integer(2)*q**Integer(2)*t**Integer(2)-t**Integer(2)+t**Integer(2)*q**Integer(4)-Integer(6)*t**Integer(4)*q**Integer(2)+q**Integer(4)*t**Integer(4)-Integer(8)*t**Integer(6)*q**Integer(4)+q**Integer(2)*t**Integer(6)+Integer(2)*t**Integer(8)*q**Integer(4)-Integer(4)*t**Integer(8)*q**Integer(6)+t**Integer(10)*q**Integer(4)+Integer(2)*t**Integer(10)*q**Integer(6)-Integer(2)*q**Integer(8)*t**Integer(12)-t**Integer(14)*q**Integer(10)+t**Integer(14)*q**Integer(8)+q**Integer(8)*t**Integer(16)+q**Integer(10)*t**Integer(16)+Integer(2)*q**Integer(10)*t**Integer(18))*q**Integer(2)/((q**Integer(3)*t**Integer(5)+Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(t*q-Integer(1))*(t*q+Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(2)*q-Integer(1))*(t**Integer(2)*q+Integer(1)))+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(-q**Integer(4)-Integer(2)*q**Integer(2)-Integer(1)-t**Integer(2)*q**Integer(4)-t**Integer(4)*q**Integer(6)+Integer(2)*q**Integer(6)*t**Integer(6)+t**Integer(6)*q**Integer(4)+t**Integer(10)*q**Integer(6)+q**Integer(8)*t**Integer(12)+t**Integer(14)*q**Integer(10))*q/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x3)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(-Integer(1)-q**Integer(2)-q**Integer(2)*t**Integer(2)+t**Integer(2)+t**Integer(4)*q**Integer(2)-q**Integer(4)*t**Integer(4)+Integer(2)*t**Integer(6)*q**Integer(4))*q*x3*x1/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x2)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*x2*x1**Integer(2)/((t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x3)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*x3*x1**Integer(2)/((t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x2)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*q**Integer(4)/((t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*x1*x2)+(t-Integer(1))**Integer(2)*(t+Integer(1))**Integer(2)*(-q**Integer(2)-Integer(1)-q**Integer(2)*t**Integer(2)-q**Integer(4)*t**Integer(4)+t**Integer(6)*q**Integer(4)+t**Integer(10)*q**Integer(6)+q**Integer(8)*t**Integer(12)+t**Integer(14)*q**Integer(10))*q*x3*x2/((t**Integer(3)*q**Integer(2)-Integer(1))*(t**Integer(3)*q**Integer(2)+Integer(1))*(t*q+Integer(1))*(t*q-Integer(1))*(q**Integer(3)*t**Integer(5)-Integer(1))*(q**Integer(3)*t**Integer(5)+Integer(1))*x1)  # needs sage.symbolic
      >>> to_SR(E[mu]) - expected           # long time (20s)                       # needs sage.symbolic
      0

      >>> E = NonSymmetricMacdonaldPolynomials(["BC",Integer(1),Integer(2)], q=q, q1=t**Integer(2), q2=-Integer(1))
      >>> omega = E.keys().fundamental_weights()
      >>> mu = -Integer(4)*omega[Integer(1)]; mu
      (-4)
      >>> expected = (t-Integer(1))*(t+Integer(1))*(-Integer(1)+q**Integer(2)*t**Integer(2)-q**Integer(2)-Integer(3)*q**Integer(10)-Integer(7)*q**Integer(26)*t**Integer(8)+Integer(5)*t**Integer(2)*q**Integer(6)-q**Integer(16)-Integer(3)*q**Integer(4)+Integer(4)*t**Integer(10)*q**Integer(30)-Integer(4)*t**Integer(6)*q**Integer(22)-Integer(10)*q**Integer(20)*t**Integer(6)+Integer(2)*q**Integer(32)*t**Integer(10)-Integer(3)*q**Integer(6)-Integer(4)*q**Integer(8)+q**Integer(34)*t**Integer(10)-Integer(4)*t**Integer(8)*q**Integer(24)-Integer(2)*q**Integer(12)-q**Integer(14)+Integer(2)*q**Integer(22)*t**Integer(10)+Integer(4)*q**Integer(26)*t**Integer(10)+Integer(4)*q**Integer(28)*t**Integer(10)+t**Integer(6)*q**Integer(30)-Integer(2)*q**Integer(32)*t**Integer(8)-Integer(2)*t**Integer(8)*q**Integer(22)+Integer(2)*q**Integer(24)*t**Integer(10)-q**Integer(20)*t**Integer(2)-Integer(2)*t**Integer(6)*q**Integer(12)+t**Integer(8)*q**Integer(14)+Integer(2)*t**Integer(4)*q**Integer(24)-Integer(4)*t**Integer(8)*q**Integer(30)+Integer(2)*t**Integer(8)*q**Integer(20)-Integer(9)*t**Integer(6)*q**Integer(16)+Integer(3)*q**Integer(26)*t**Integer(6)+q**Integer(28)*t**Integer(6)+Integer(3)*t**Integer(2)*q**Integer(4)+Integer(2)*q**Integer(18)*t**Integer(8)-Integer(6)*t**Integer(6)*q**Integer(14)+Integer(4)*t**Integer(4)*q**Integer(22)-Integer(2)*q**Integer(24)*t**Integer(6)+Integer(3)*t**Integer(2)*q**Integer(12)+Integer(7)*t**Integer(4)*q**Integer(20)-t**Integer(2)*q**Integer(16)+Integer(11)*q**Integer(18)*t**Integer(4)-Integer(2)*t**Integer(2)*q**Integer(18)+Integer(9)*q**Integer(16)*t**Integer(4)-t**Integer(4)*q**Integer(6)+Integer(6)*q**Integer(8)*t**Integer(2)+Integer(5)*q**Integer(10)*t**Integer(2)-Integer(6)*q**Integer(28)*t**Integer(8)+q**Integer(12)*t**Integer(4)+Integer(8)*t**Integer(4)*q**Integer(14)-Integer(10)*t**Integer(6)*q**Integer(18)-q**Integer(4)*t**Integer(4)+q**Integer(16)*t**Integer(8)-Integer(2)*t**Integer(4)*q**Integer(8))/((t*q**Integer(4)-Integer(1))*(t*q**Integer(4)+Integer(1))*(q**Integer(7)*t**Integer(2)-Integer(1))*(q**Integer(7)*t**Integer(2)+Integer(1))*(t*q**Integer(3)-Integer(1))*(t*q**Integer(3)+Integer(1))*(q**Integer(5)*t**Integer(2)+Integer(1))*(q**Integer(5)*t**Integer(2)-Integer(1)))+(q**Integer(2)+Integer(1))*(q**Integer(4)+Integer(1))*(t-Integer(1))*(t+Integer(1))*(-Integer(1)+q**Integer(2)*t**Integer(2)-q**Integer(2)+t**Integer(2)*q**Integer(6)-q**Integer(4)+t**Integer(6)*q**Integer(22)+Integer(3)*q**Integer(10)*t**Integer(4)+t**Integer(2)-q**Integer(8)-Integer(2)*t**Integer(8)*q**Integer(24)+q**Integer(22)*t**Integer(10)+q**Integer(26)*t**Integer(10)-Integer(2)*t**Integer(8)*q**Integer(22)+q**Integer(24)*t**Integer(10)-Integer(4)*t**Integer(6)*q**Integer(12)-Integer(2)*t**Integer(8)*q**Integer(20)-Integer(3)*t**Integer(6)*q**Integer(16)+Integer(2)*t**Integer(2)*q**Integer(4)-t**Integer(6)*q**Integer(10)-Integer(2)*t**Integer(6)*q**Integer(14)+t**Integer(8)*q**Integer(12)-t**Integer(2)*q**Integer(12)+Integer(2)*q**Integer(16)*t**Integer(4)+q**Integer(8)*t**Integer(2)-q**Integer(10)*t**Integer(2)+Integer(3)*q**Integer(12)*t**Integer(4)+Integer(2)*t**Integer(4)*q**Integer(14)+t**Integer(6)*q**Integer(18)-Integer(2)*q**Integer(4)*t**Integer(4)+q**Integer(16)*t**Integer(8)+q**Integer(20)*t**Integer(10))*q*x1/((t*q**Integer(4)-Integer(1))*(t*q**Integer(4)+Integer(1))*(q**Integer(7)*t**Integer(2)-Integer(1))*(q**Integer(7)*t**Integer(2)+Integer(1))*(t*q**Integer(3)-Integer(1))*(t*q**Integer(3)+Integer(1))*(q**Integer(5)*t**Integer(2)+Integer(1))*(q**Integer(5)*t**Integer(2)-Integer(1)))+(q**Integer(2)+Integer(1))*(q**Integer(4)+Integer(1))*(t-Integer(1))*(t+Integer(1))*(Integer(1)+q**Integer(8)+q**Integer(4)+q**Integer(2)-q**Integer(8)*t**Integer(2)-Integer(2)*t**Integer(2)*q**Integer(4)-t**Integer(2)*q**Integer(6)+t**Integer(2)*q**Integer(12)-t**Integer(2)+t**Integer(4)*q**Integer(6)-Integer(2)*q**Integer(16)*t**Integer(4)-t**Integer(4)*q**Integer(14)-Integer(2)*q**Integer(12)*t**Integer(4)+t**Integer(6)*q**Integer(12)+t**Integer(6)*q**Integer(16)+t**Integer(6)*q**Integer(18)+t**Integer(6)*q**Integer(14))*q/((t*q**Integer(4)-Integer(1))*(t*q**Integer(4)+Integer(1))*(q**Integer(7)*t**Integer(2)-Integer(1))*(q**Integer(7)*t**Integer(2)+Integer(1))*(t*q**Integer(3)-Integer(1))*(t*q**Integer(3)+Integer(1))*x1)+(t-Integer(1))*(t+Integer(1))*(-Integer(1)-q**Integer(2)-q**Integer(6)-q**Integer(4)-q**Integer(8)+t**Integer(2)*q**Integer(4)-t**Integer(2)*q**Integer(14)+t**Integer(2)*q**Integer(6)-q**Integer(10)*t**Integer(2)+q**Integer(8)*t**Integer(2)-t**Integer(2)*q**Integer(12)+q**Integer(12)*t**Integer(4)+q**Integer(10)*t**Integer(4)+q**Integer(16)*t**Integer(4)+Integer(2)*t**Integer(4)*q**Integer(14))*(q**Integer(4)+Integer(1))/((q**Integer(7)*t**Integer(2)+Integer(1))*(q**Integer(7)*t**Integer(2)-Integer(1))*(t*q**Integer(4)-Integer(1))*(t*q**Integer(4)+Integer(1))*x1**Integer(2))+(t-Integer(1))*(t+Integer(1))*(q**Integer(4)+Integer(1))*(q**Integer(2)+Integer(1))*q/((t*q**Integer(4)-Integer(1))*(t*q**Integer(4)+Integer(1))*x1**Integer(3))+(q**Integer(4)+Integer(1))*(t-Integer(1))*(t+Integer(1))*(Integer(1)+q**Integer(6)+q**Integer(8)+q**Integer(2)+q**Integer(4)-q**Integer(2)*t**Integer(2)-Integer(3)*t**Integer(2)*q**Integer(4)+q**Integer(10)*t**Integer(2)+t**Integer(2)*q**Integer(12)-Integer(2)*t**Integer(2)*q**Integer(6)-q**Integer(8)*t**Integer(2)-Integer(2)*q**Integer(16)*t**Integer(4)+q**Integer(4)*t**Integer(4)+t**Integer(4)*q**Integer(6)-q**Integer(10)*t**Integer(4)-Integer(2)*q**Integer(12)*t**Integer(4)-Integer(2)*t**Integer(4)*q**Integer(14)+t**Integer(6)*q**Integer(12)+t**Integer(6)*q**Integer(18)+Integer(2)*t**Integer(6)*q**Integer(16)+t**Integer(6)*q**Integer(14))*x1**Integer(2)/((t*q**Integer(4)-Integer(1))*(t*q**Integer(4)+Integer(1))*(q**Integer(7)*t**Integer(2)-Integer(1))*(q**Integer(7)*t**Integer(2)+Integer(1))*(t*q**Integer(3)-Integer(1))*(t*q**Integer(3)+Integer(1)))+(t-Integer(1))*(t+Integer(1))*(-Integer(1)-t**Integer(2)*q**Integer(6)+t**Integer(2)+t**Integer(4)*q**Integer(8))*(q**Integer(4)+Integer(1))*(q**Integer(2)+Integer(1))*q*x1**Integer(3)/((q**Integer(7)*t**Integer(2)+Integer(1))*(q**Integer(7)*t**Integer(2)-Integer(1))*(t*q**Integer(4)-Integer(1))*(t*q**Integer(4)+Integer(1)))+Integer(1)/x1**Integer(4)+(t-Integer(1))*(t+Integer(1))*x1**Integer(4)/((t*q**Integer(4)-Integer(1))*(t*q**Integer(4)+Integer(1)))  # needs sage.symbolic
      >>> to_SR(E[mu]) - expected                                                   # needs sage.symbolic
      0

  Type \(BC\) dual, comparison with hand calculations by Bogdan Ion:

  Sage

      sage: K = QQ['q,q1,q2'].fraction_field()
      sage: q,q1,q2 = K.gens()
      sage: ct = CartanType(["BC",2,2]).dual()
      sage: E = NonSymmetricMacdonaldPolynomials(ct, q=q, q1=q1, q2=q2)
      sage: KL = E.domain(); KL
      Algebra of the Ambient space of the Root system of type ['B', 2]
      over Fraction Field of Multivariate Polynomial Ring in q, q1, q2 over Rational Field
      sage: alpha = E.keys().simple_roots(); alpha
      Finite family {1: (1, -1), 2: (0, 1)}
      sage: omega=E.keys().fundamental_weights(); omega
      Finite family {1: (1, 0), 2: (1/2, 1/2)}
      sage: epsilon = E.keys().basis(); epsilon
      Finite family {0: (1, 0), 1: (0, 1)}

  [Python]

      >>> from sage.all import *
      >>> K = QQ['q,q1,q2'].fraction_field()
      >>> q,q1,q2 = K.gens()
      >>> ct = CartanType(["BC",Integer(2),Integer(2)]).dual()
      >>> E = NonSymmetricMacdonaldPolynomials(ct, q=q, q1=q1, q2=q2)
      >>> KL = E.domain(); KL
      Algebra of the Ambient space of the Root system of type ['B', 2]
      over Fraction Field of Multivariate Polynomial Ring in q, q1, q2 over Rational Field
      >>> alpha = E.keys().simple_roots(); alpha
      Finite family {1: (1, -1), 2: (0, 1)}
      >>> omega=E.keys().fundamental_weights(); omega
      Finite family {1: (1, 0), 2: (1/2, 1/2)}
      >>> epsilon = E.keys().basis(); epsilon
      Finite family {0: (1, 0), 1: (0, 1)}

  Note: Sage’s \(q\) is the usual \(q^2\):

  Sage

      sage: E.L().null_root()
      e['delta']
      sage: E.L().null_coroot()
      2*e['deltacheck']

  Python

      >>> from sage.all import *
      >>> E.L().null_root()
      e['delta']
      >>> E.L().null_coroot()
      2*e['deltacheck']

  Some eigenvectors:

  Sage

      sage: E[0*omega[1]]
      B[(0, 0)]
      sage: E[omega[1]]
      -((q^2*q1^3*q2+q^2*q1^2*q2^2)/(q^2*q1^4-q2^4))*B[(0, 0)] + B[(1, 0)]
      sage: Eomega1 = (KL.one() * (q^2*(-q1/q2)^2*(1-(-q1/q2))) / (1-q^2*(-q1/q2)^4)
      ....:             + KL.monomial(omega[1]))
      sage: E[omega[1]] == Eomega1
      True

  [Python]

      >>> from sage.all import *
      >>> E[Integer(0)*omega[Integer(1)]]
      B[(0, 0)]
      >>> E[omega[Integer(1)]]
      -((q^2*q1^3*q2+q^2*q1^2*q2^2)/(q^2*q1^4-q2^4))*B[(0, 0)] + B[(1, 0)]
      >>> Eomega1 = (KL.one() * (q**Integer(2)*(-q1/q2)**Integer(2)*(Integer(1)-(-q1/q2))) / (Integer(1)-q**Integer(2)*(-q1/q2)**Integer(4))
      ...             + KL.monomial(omega[Integer(1)]))
      >>> E[omega[Integer(1)]] == Eomega1
      True

  Checking the \(Y\) s:

  Sage

      sage: Y = E.Y()
      sage: alphacheck = Y.keys().simple_roots()
      sage: Y0 = Y[alphacheck[0]]
      sage: Y1 = Y[alphacheck[1]]
      sage: Y2 = Y[alphacheck[2]]

      sage: Y0.word, Y0.signs, Y0.scalar
      ((0, 1, 2, 1, 0, 1, 2, 1), (-1, -1, -1, -1, -1, -1, -1, -1), q1^4*q2^4/q^2)
      sage: Y1.word, Y1.signs, Y1.scalar
      ((1, 2, 0, 1, 2, 0), (1, 1, -1, 1, -1, 1), 1/(-q1*q2))
      sage: Y2.word, Y2.signs, Y2.scalar
      ((2, 1, 0, 1), (1, 1, 1, -1), 1/(-q1*q2))

      sage: E.eigenvalues(0*omega[1])
      [q2^4/(q^2*q1^4), q1/(-q2), q1/(-q2)]

  Python

      >>> from sage.all import *
      >>> Y = E.Y()
      >>> alphacheck = Y.keys().simple_roots()
      >>> Y0 = Y[alphacheck[Integer(0)]]
      >>> Y1 = Y[alphacheck[Integer(1)]]
      >>> Y2 = Y[alphacheck[Integer(2)]]

      >>> Y0.word, Y0.signs, Y0.scalar
      ((0, 1, 2, 1, 0, 1, 2, 1), (-1, -1, -1, -1, -1, -1, -1, -1), q1^4*q2^4/q^2)
      >>> Y1.word, Y1.signs, Y1.scalar
      ((1, 2, 0, 1, 2, 0), (1, 1, -1, 1, -1, 1), 1/(-q1*q2))
      >>> Y2.word, Y2.signs, Y2.scalar
      ((2, 1, 0, 1), (1, 1, 1, -1), 1/(-q1*q2))

      >>> E.eigenvalues(Integer(0)*omega[Integer(1)])
      [q2^4/(q^2*q1^4), q1/(-q2), q1/(-q2)]

  Checking the \(T\) and \(T^{-1}\) s:

  Sage

      sage: T = E._T_Y
      sage: Tinv0 = T.Tw_inverse([0])
      sage: Tinv1 = T.Tw_inverse([1])
      sage: Tinv2 = T.Tw_inverse([2])

      sage: for x in [0*epsilon[0], -epsilon[0], -epsilon[1], epsilon[0], epsilon[1]]:
      ....:     x = KL.monomial(x)
      ....:     assert Tinv0(T[0](x)) == x and T[0](Tinv0(x)) == x
      ....:     assert Tinv1(T[1](x)) == x and T[1](Tinv1(x)) == x
      ....:     assert Tinv2(T[2](x)) == x and T[2](Tinv2(x)) == x

      sage: start = E[omega[1]]; start
      -((q^2*q1^3*q2+q^2*q1^2*q2^2)/(q^2*q1^4-q2^4))*B[(0, 0)] + B[(1, 0)]
      sage: Tinv1(Tinv2(Tinv1(Tinv0(Tinv1(Tinv2(Tinv1(Tinv0(start)))))))) * (q1*q2)^4/q^2 == Y0(start)
      True
      sage: Y0(start) == q^2*q1^4/q2^4 * start
      True

  [Python]

      >>> from sage.all import *
      >>> T = E._T_Y
      >>> Tinv0 = T.Tw_inverse([Integer(0)])
      >>> Tinv1 = T.Tw_inverse([Integer(1)])
      >>> Tinv2 = T.Tw_inverse([Integer(2)])

      >>> for x in [Integer(0)*epsilon[Integer(0)], -epsilon[Integer(0)], -epsilon[Integer(1)], epsilon[Integer(0)], epsilon[Integer(1)]]:
      ...     x = KL.monomial(x)
      ...     assert Tinv0(T[Integer(0)](x)) == x and T[Integer(0)](Tinv0(x)) == x
      ...     assert Tinv1(T[Integer(1)](x)) == x and T[Integer(1)](Tinv1(x)) == x
      ...     assert Tinv2(T[Integer(2)](x)) == x and T[Integer(2)](Tinv2(x)) == x

      >>> start = E[omega[Integer(1)]]; start
      -((q^2*q1^3*q2+q^2*q1^2*q2^2)/(q^2*q1^4-q2^4))*B[(0, 0)] + B[(1, 0)]
      >>> Tinv1(Tinv2(Tinv1(Tinv0(Tinv1(Tinv2(Tinv1(Tinv0(start)))))))) * (q1*q2)**Integer(4)/q**Integer(2) == Y0(start)
      True
      >>> Y0(start) == q**Integer(2)*q1**Integer(4)/q2**Integer(4) * start
      True

  Checking the relation between the \(Y\) s:

  Sage

      sage: q^2 * Y0(Y1(Y1(Y2(Y2(start))))) == start
      True
      sage: for x in [0*epsilon[0], -epsilon[0], -epsilon[1], epsilon[0], epsilon[1]]:
      ....:     x = KL.monomial(x)
      ....:     assert q^2 * Y0(Y1(Y1(Y2(Y2(start))))) == start

  Python

      >>> from sage.all import *
      >>> q**Integer(2) * Y0(Y1(Y1(Y2(Y2(start))))) == start
      True
      >>> for x in [Integer(0)*epsilon[Integer(0)], -epsilon[Integer(0)], -epsilon[Integer(1)], epsilon[Integer(0)], epsilon[Integer(1)]]:
      ...     x = KL.monomial(x)
      ...     assert q**Integer(2) * Y0(Y1(Y1(Y2(Y2(start))))) == start

  KL0()

    Return the group algebra where the nonsymmetric Macdonald polynomials live.

    EXAMPLES:

    Sage

        sage: NonSymmetricMacdonaldPolynomials("B2~").KL0()
        Algebra of the Ambient space of the Root system of type ['B', 2]
        over Fraction Field of Multivariate Polynomial Ring in q, q1, q2 over Rational Field
        sage: NonSymmetricMacdonaldPolynomials("B2~*").KL0()
        Algebra of the Ambient space of the Root system of type ['C', 2]
        over Fraction Field of Multivariate Polynomial Ring in q, q1, q2 over Rational Field

    Python

        >>> from sage.all import *
        >>> NonSymmetricMacdonaldPolynomials("B2~").KL0()
        Algebra of the Ambient space of the Root system of type ['B', 2]
        over Fraction Field of Multivariate Polynomial Ring in q, q1, q2 over Rational Field
        >>> NonSymmetricMacdonaldPolynomials("B2~*").KL0()
        Algebra of the Ambient space of the Root system of type ['C', 2]
        over Fraction Field of Multivariate Polynomial Ring in q, q1, q2 over Rational Field

  L()

    Return the affinization of the classical weight space.

    EXAMPLES:

    Sage

        sage: NonSymmetricMacdonaldPolynomials(["B", 2, 1]).L()
        Ambient space of the Root system of type ['B', 2, 1]

    Python

        >>> from sage.all import *
        >>> NonSymmetricMacdonaldPolynomials(["B", Integer(2), Integer(1)]).L()
        Ambient space of the Root system of type ['B', 2, 1]

  L0()

    Return the space indexing the monomials of the nonsymmetric Macdonald polynomials.

    EXAMPLES:

    Sage

        sage: NonSymmetricMacdonaldPolynomials("B2~").L0()
        Ambient space of the Root system of type ['B', 2]
        sage: NonSymmetricMacdonaldPolynomials("B2~*").L0()
        Ambient space of the Root system of type ['C', 2]

    Python

        >>> from sage.all import *
        >>> NonSymmetricMacdonaldPolynomials("B2~").L0()
        Ambient space of the Root system of type ['B', 2]
        >>> NonSymmetricMacdonaldPolynomials("B2~*").L0()
        Ambient space of the Root system of type ['C', 2]

  L_check()

    Return the other affinization of the classical weight space.

    Todo

    should this just return \(L\) in the simply laced case?

    EXAMPLES:

    Sage

        sage: NonSymmetricMacdonaldPolynomials(["B", 2, 1]).L_check()
        Coambient space of the Root system of type ['C', 2, 1]
        sage: NonSymmetricMacdonaldPolynomials(["B", 2, 1]).L_check().classical()
        Ambient space of the Root system of type ['B', 2]

    Python

        >>> from sage.all import *
        >>> NonSymmetricMacdonaldPolynomials(["B", Integer(2), Integer(1)]).L_check()
        Coambient space of the Root system of type ['C', 2, 1]
        >>> NonSymmetricMacdonaldPolynomials(["B", Integer(2), Integer(1)]).L_check().classical()
        Ambient space of the Root system of type ['B', 2]

  L_prime()

    The affine space where classical weights are lifted for the recursion.

    Also the parent of \(\rho'\).

    EXAMPLES:

    In the twisted case, this is the affinization of the classical ambient space:

    Sage

        sage: NonSymmetricMacdonaldPolynomials("B2~*").L()
        Ambient space of the Root system of type ['B', 2, 1]^*
        sage: NonSymmetricMacdonaldPolynomials("B2~*").L().classical()
        Ambient space of the Root system of type ['C', 2]

        sage: NonSymmetricMacdonaldPolynomials("B2~*").L_prime()
        Ambient space of the Root system of type ['B', 2, 1]^*
        sage: NonSymmetricMacdonaldPolynomials("B2~*").L_prime().classical()
        Ambient space of the Root system of type ['C', 2]

    Python

        >>> from sage.all import *
        >>> NonSymmetricMacdonaldPolynomials("B2~*").L()
        Ambient space of the Root system of type ['B', 2, 1]^*
        >>> NonSymmetricMacdonaldPolynomials("B2~*").L().classical()
        Ambient space of the Root system of type ['C', 2]

        >>> NonSymmetricMacdonaldPolynomials("B2~*").L_prime()
        Ambient space of the Root system of type ['B', 2, 1]^*
        >>> NonSymmetricMacdonaldPolynomials("B2~*").L_prime().classical()
        Ambient space of the Root system of type ['C', 2]

    In the untwisted case, this is the other affinization of the classical ambient space:

    Sage

        sage: NonSymmetricMacdonaldPolynomials("B2~").L()
        Ambient space of the Root system of type ['B', 2, 1]
        sage: NonSymmetricMacdonaldPolynomials("B2~").L().classical()
        Ambient space of the Root system of type ['B', 2]

        sage: NonSymmetricMacdonaldPolynomials("B2~").L_prime()
        Coambient space of the Root system of type ['C', 2, 1]
        sage: NonSymmetricMacdonaldPolynomials("B2~").L_prime().classical()
        Ambient space of the Root system of type ['B', 2]

    [Python]

        >>> from sage.all import *
        >>> NonSymmetricMacdonaldPolynomials("B2~").L()
        Ambient space of the Root system of type ['B', 2, 1]
        >>> NonSymmetricMacdonaldPolynomials("B2~").L().classical()
        Ambient space of the Root system of type ['B', 2]

        >>> NonSymmetricMacdonaldPolynomials("B2~").L_prime()
        Coambient space of the Root system of type ['C', 2, 1]
        >>> NonSymmetricMacdonaldPolynomials("B2~").L_prime().classical()
        Ambient space of the Root system of type ['B', 2]

    For simply laced, the two affinizations coincide:

    Sage

        sage: NonSymmetricMacdonaldPolynomials("A2~").L()
        Ambient space of the Root system of type ['A', 2, 1]
        sage: NonSymmetricMacdonaldPolynomials("A2~").L().classical()
        Ambient space of the Root system of type ['A', 2]

        sage: NonSymmetricMacdonaldPolynomials("A2~").L_prime()
        Coambient space of the Root system of type ['A', 2, 1]
        sage: NonSymmetricMacdonaldPolynomials("A2~").L_prime().classical()
        Ambient space of the Root system of type ['A', 2]

    Python

        >>> from sage.all import *
        >>> NonSymmetricMacdonaldPolynomials("A2~").L()
        Ambient space of the Root system of type ['A', 2, 1]
        >>> NonSymmetricMacdonaldPolynomials("A2~").L().classical()
        Ambient space of the Root system of type ['A', 2]

        >>> NonSymmetricMacdonaldPolynomials("A2~").L_prime()
        Coambient space of the Root system of type ['A', 2, 1]
        >>> NonSymmetricMacdonaldPolynomials("A2~").L_prime().classical()
        Ambient space of the Root system of type ['A', 2]

    Note

    do we want the coambient space of type \(A_2^{(1)}\) instead?

    For type BC:

    Sage

        sage: NonSymmetricMacdonaldPolynomials(["BC",3,2]).L_prime()
        Ambient space of the Root system of type ['BC', 3, 2]

    [Python]

        >>> from sage.all import *
        >>> NonSymmetricMacdonaldPolynomials(["BC",Integer(3),Integer(2)]).L_prime()
        Ambient space of the Root system of type ['BC', 3, 2]

  Q_to_Qcheck()

    The reindexing of the index set of the Y’s by the coroot lattice.

    EXAMPLES:

    Sage

        sage: E = NonSymmetricMacdonaldPolynomials("C2~")
        sage: alphacheck = E.Y().keys().simple_roots()
        sage: E.Q_to_Qcheck(alphacheck[0])
        alphacheck[0] - alphacheck[2]
        sage: E.Q_to_Qcheck(alphacheck[1])
        alphacheck[1]
        sage: E.Q_to_Qcheck(alphacheck[2])
        alphacheck[2]

        sage: x = alphacheck[1] + 2*alphacheck[2]
        sage: x.parent()
        Root lattice of the Root system of type ['B', 2, 1]
        sage: E.Q_to_Qcheck(x)
        alphacheck[1] + 2*alphacheck[2]
        sage: _.parent()
        Coroot lattice of the Root system of type ['C', 2, 1]

    Python

        >>> from sage.all import *
        >>> E = NonSymmetricMacdonaldPolynomials("C2~")
        >>> alphacheck = E.Y().keys().simple_roots()
        >>> E.Q_to_Qcheck(alphacheck[Integer(0)])
        alphacheck[0] - alphacheck[2]
        >>> E.Q_to_Qcheck(alphacheck[Integer(1)])
        alphacheck[1]
        >>> E.Q_to_Qcheck(alphacheck[Integer(2)])
        alphacheck[2]

        >>> x = alphacheck[Integer(1)] + Integer(2)*alphacheck[Integer(2)]
        >>> x.parent()
        Root lattice of the Root system of type ['B', 2, 1]
        >>> E.Q_to_Qcheck(x)
        alphacheck[1] + 2*alphacheck[2]
        >>> _.parent()
        Coroot lattice of the Root system of type ['C', 2, 1]

  Y()

    Return the family of \(Y\) operators whose eigenvectors are the nonsymmetric Macdonald polynomials.

    EXAMPLES:

    Sage

        sage: NonSymmetricMacdonaldPolynomials("C2~").Y()
        Lazy family (<lambda>(i))_{i in Root lattice of the Root system of type ['B', 2, 1]}
        sage: _.keys().classical()
        Root lattice of the Root system of type ['B', 2]
        sage: NonSymmetricMacdonaldPolynomials("C2~*").Y()
        Lazy family (<...Y_lambdacheck...>(i))_{i in Coroot lattice of the Root system of type ['C', 2, 1]^*}
        sage: _.keys().classical()
        Root lattice of the Root system of type ['C', 2]
        sage: NonSymmetricMacdonaldPolynomials(["BC", 3, 2]).Y()
        Lazy family (<...Y_lambdacheck...>(i))_{i in Coroot lattice of the Root system of type ['BC', 3, 2]}
        sage: _.keys().classical()
        Root lattice of the Root system of type ['B', 3]

    Python

        >>> from sage.all import *
        >>> NonSymmetricMacdonaldPolynomials("C2~").Y()
        Lazy family (<lambda>(i))_{i in Root lattice of the Root system of type ['B', 2, 1]}
        >>> _.keys().classical()
        Root lattice of the Root system of type ['B', 2]
        >>> NonSymmetricMacdonaldPolynomials("C2~*").Y()
        Lazy family (<...Y_lambdacheck...>(i))_{i in Coroot lattice of the Root system of type ['C', 2, 1]^*}
        >>> _.keys().classical()
        Root lattice of the Root system of type ['C', 2]
        >>> NonSymmetricMacdonaldPolynomials(["BC", Integer(3), Integer(2)]).Y()
        Lazy family (<...Y_lambdacheck...>(i))_{i in Coroot lattice of the Root system of type ['BC', 3, 2]}
        >>> _.keys().classical()
        Root lattice of the Root system of type ['B', 3]

  affine_lift(mu)

    Return the affinization of \(\mu\) in \(L'\).

    INPUT:

    - `mu` – a classical weight \(\mu\)

    See also

    - `hecke_algebra_representation.CherednikOperatorsEigenvectors.affine_lift()`

    - `affine_retract()`

    - `L_prime()`

    EXAMPLES:

    In the untwisted case, this is the other affinization at level 1:

    Sage

        sage: E = NonSymmetricMacdonaldPolynomials("B2~")
        sage: L0 = E.keys(); L0
        Ambient space of the Root system of type ['B', 2]
        sage: omega = L0.fundamental_weights()
        sage: E.affine_lift(omega[1])
        e[0] + e['deltacheck']
        sage: E.affine_lift(omega[1]).parent()
        Coambient space of the Root system of type ['C', 2, 1]

    Python

        >>> from sage.all import *
        >>> E = NonSymmetricMacdonaldPolynomials("B2~")
        >>> L0 = E.keys(); L0
        Ambient space of the Root system of type ['B', 2]
        >>> omega = L0.fundamental_weights()
        >>> E.affine_lift(omega[Integer(1)])
        e[0] + e['deltacheck']
        >>> E.affine_lift(omega[Integer(1)]).parent()
        Coambient space of the Root system of type ['C', 2, 1]

    In the twisted case, this is the usual affinization at level 1:

    Sage

        sage: E = NonSymmetricMacdonaldPolynomials("B2~*")
        sage: L0 = E.keys(); L0
        Ambient space of the Root system of type ['C', 2]
        sage: omega = L0.fundamental_weights()
        sage: E.affine_lift(omega[1])
        e[0] + e['deltacheck']
        sage: E.affine_lift(omega[1]).parent()
        Ambient space of the Root system of type ['B', 2, 1]^*

    [Python]

        >>> from sage.all import *
        >>> E = NonSymmetricMacdonaldPolynomials("B2~*")
        >>> L0 = E.keys(); L0
        Ambient space of the Root system of type ['C', 2]
        >>> omega = L0.fundamental_weights()
        >>> E.affine_lift(omega[Integer(1)])
        e[0] + e['deltacheck']
        >>> E.affine_lift(omega[Integer(1)]).parent()
        Ambient space of the Root system of type ['B', 2, 1]^*

  affine_retract(mu)

    Retract the affine weight \(\mu\) into a classical weight.

    INPUT:

    - `mu` – an affine weight \(\mu\) in \(L'\)

    See also

    - `hecke_algebra_representation.HeckeAlgebraRepresentation.affine_retract()`

    - `affine_lift()`

    - `L_prime()`

    EXAMPLES:

    Sage

        sage: E = NonSymmetricMacdonaldPolynomials("B2~")
        sage: L0 = E.keys(); L0
        Ambient space of the Root system of type ['B', 2]
        sage: omega = L0.fundamental_weights()
        sage: E.affine_lift(omega[1])
        e[0] + e['deltacheck']
        sage: E.affine_retract(E.affine_lift(omega[1]))
        (1, 0)

    Python

        >>> from sage.all import *
        >>> E = NonSymmetricMacdonaldPolynomials("B2~")
        >>> L0 = E.keys(); L0
        Ambient space of the Root system of type ['B', 2]
        >>> omega = L0.fundamental_weights()
        >>> E.affine_lift(omega[Integer(1)])
        e[0] + e['deltacheck']
        >>> E.affine_retract(E.affine_lift(omega[Integer(1)]))
        (1, 0)

  cartan_type()

    Return Cartan type of `self`.

    EXAMPLES:

    Sage

        sage: NonSymmetricMacdonaldPolynomials(["B", 2, 1]).cartan_type()
        ['B', 2, 1]

    Python

        >>> from sage.all import *
        >>> NonSymmetricMacdonaldPolynomials(["B", Integer(2), Integer(1)]).cartan_type()
        ['B', 2, 1]

  eigenvalue_experimental(mu, l)

    Return the eigenvalue of \(Y^{\lambda^\vee}\) acting on the macdonald polynomial \(E_\mu\).

    INPUT:

    - `mu` – the index \(\mu\) of an eigenvector

    - `l` – an index \(\lambda^\vee\) of some \(Y\)

    Note

    - This method is currently not used; most tests below even test the naive method. They are left here as a basis for a future implementation.

    - This is actually equivariant, as long as \(s_i\) does not fix \(\lambda\).

    - This method is only really needed for \(\lambda^\vee=\alpha^\vee_i\) with \(i=0,...,n\).

    See Corollary 6.11 of [Haiman06].

    EXAMPLES:

    Sage

        sage: K = QQ['q,t'].fraction_field()
        sage: q,t = K.gens()
        sage: q1 = t
        sage: q2 = -1
        sage: KL = RootSystem(["A",1,1]).ambient_space().algebra(K)
        sage: E = NonSymmetricMacdonaldPolynomials(KL,q, q1, q2)
        sage: L0 = E.keys()
        sage: E.eigenvalues(L0([0,0]))  # Checked by hand by Mark and Arun          # needs sage.libs.gap
        [1/(q*t), t]
        sage: alpha = E.Y().keys().simple_roots()
        sage: E.eigenvalue_experimental(L0([0,0]), alpha[0]) # todo: not implemented
        1/(q*t)
        sage: E.eigenvalue_experimental(L0([0,0]), alpha[1])
        t

    Python

        >>> from sage.all import *
        >>> K = QQ['q,t'].fraction_field()
        >>> q,t = K.gens()
        >>> q1 = t
        >>> q2 = -Integer(1)
        >>> KL = RootSystem(["A",Integer(1),Integer(1)]).ambient_space().algebra(K)
        >>> E = NonSymmetricMacdonaldPolynomials(KL,q, q1, q2)
        >>> L0 = E.keys()
        >>> E.eigenvalues(L0([Integer(0),Integer(0)]))  # Checked by hand by Mark and Arun          # needs sage.libs.gap
        [1/(q*t), t]
        >>> alpha = E.Y().keys().simple_roots()
        >>> E.eigenvalue_experimental(L0([Integer(0),Integer(0)]), alpha[Integer(0)]) # todo: not implemented
        1/(q*t)
        >>> E.eigenvalue_experimental(L0([Integer(0),Integer(0)]), alpha[Integer(1)])
        t

    Some examples of eigenvalues (not mathematically checked!!!):

    Sage

        sage: # needs sage.libs.gap
        sage: E.eigenvalues(L0([1,0]))
        [t, 1/(q*t)]
        sage: E.eigenvalues(L0([0,1]))
        [1/(q^2*t), q*t]
        sage: E.eigenvalues(L0([1,1]))
        [1/(q*t), t]
        sage: E.eigenvalues(L0([2,1]))
        [t, 1/(q*t)]
        sage: E.eigenvalues(L0([-1,1]))
        [(-1)/(-q^3*t), q^2*t]
        sage: E.eigenvalues(L0([-2,1]))
        [(-1)/(-q^4*t), q^3*t]
        sage: E.eigenvalues(L0([-2,0]))
        [(-1)/(-q^3*t), q^2*t]

    [Python]

        >>> from sage.all import *
        >>> # needs sage.libs.gap
        >>> E.eigenvalues(L0([Integer(1),Integer(0)]))
        [t, 1/(q*t)]
        >>> E.eigenvalues(L0([Integer(0),Integer(1)]))
        [1/(q^2*t), q*t]
        >>> E.eigenvalues(L0([Integer(1),Integer(1)]))
        [1/(q*t), t]
        >>> E.eigenvalues(L0([Integer(2),Integer(1)]))
        [t, 1/(q*t)]
        >>> E.eigenvalues(L0([-Integer(1),Integer(1)]))
        [(-1)/(-q^3*t), q^2*t]
        >>> E.eigenvalues(L0([-Integer(2),Integer(1)]))
        [(-1)/(-q^4*t), q^3*t]
        >>> E.eigenvalues(L0([-Integer(2),Integer(0)]))
        [(-1)/(-q^3*t), q^2*t]

    Some type \(B\) examples:

    Sage

        sage: K = QQ['q,t'].fraction_field()
        sage: q,t = K.gens()
        sage: q1 = t
        sage: q2 = -1
        sage: L = RootSystem(["B",2,1]).ambient_space()
        sage: KL = L.algebra(K)
        sage: E = NonSymmetricMacdonaldPolynomials(KL,q, q1, q2)
        sage: L0 = E.keys()
        sage: alpha = L.simple_coroots()

        sage: # not tested
        sage: E.eigenvalue(L0((0,0)), alpha[0])  # not checked
        q/t
        sage: E.eigenvalue(L0((1,0)), alpha[1])  # What Mark got by hand
        q
        sage: E.eigenvalue(L0((1,0)), alpha[2])  # not checked
        t
        sage: E.eigenvalue(L0((1,0)), alpha[0])  # not checked
        1

        sage: L = RootSystem("B2~*").ambient_space()
        sage: KL = L.algebra(K)
        sage: E = NonSymmetricMacdonaldPolynomials(KL,q, q1, q2)
        sage: L0 = E.keys()
        sage: alpha = L.simple_coroots()
        sage: E.eigenvalue(L0((0,0)), alpha[0]) # assuming Mark's calculation is correct, one should get # not tested
        1/(q*t^2)

    Python

        >>> from sage.all import *
        >>> K = QQ['q,t'].fraction_field()
        >>> q,t = K.gens()
        >>> q1 = t
        >>> q2 = -Integer(1)
        >>> L = RootSystem(["B",Integer(2),Integer(1)]).ambient_space()
        >>> KL = L.algebra(K)
        >>> E = NonSymmetricMacdonaldPolynomials(KL,q, q1, q2)
        >>> L0 = E.keys()
        >>> alpha = L.simple_coroots()

        >>> # not tested
        >>> E.eigenvalue(L0((Integer(0),Integer(0))), alpha[Integer(0)])  # not checked
        q/t
        >>> E.eigenvalue(L0((Integer(1),Integer(0))), alpha[Integer(1)])  # What Mark got by hand
        q
        >>> E.eigenvalue(L0((Integer(1),Integer(0))), alpha[Integer(2)])  # not checked
        t
        >>> E.eigenvalue(L0((Integer(1),Integer(0))), alpha[Integer(0)])  # not checked
        1

        >>> L = RootSystem("B2~*").ambient_space()
        >>> KL = L.algebra(K)
        >>> E = NonSymmetricMacdonaldPolynomials(KL,q, q1, q2)
        >>> L0 = E.keys()
        >>> alpha = L.simple_coroots()
        >>> E.eigenvalue(L0((Integer(0),Integer(0))), alpha[Integer(0)]) # assuming Mark's calculation is correct, one should get # not tested
        1/(q*t^2)

    The expected value can more or less be read off from equation (37), Corollary 6.15 of [Haiman06]

    Todo

    - Use proposition 6.9 of [Haiman06] to check the action of the \(Y\) s on monomials.

    - Generalize to any \(q_1\), \(q_2\).

    - Check claim by Mark: all scalar products should occur in the finite weight lattice, with alpha 0 being the appropriate projection of the affine alpha 0. Question: can this be emulated by being at level 0?

  rho_prime()

    Return the level 0 sum of the classical fundamental weights in \(L'\).

    See also

    `L_prime()`

    EXAMPLES:

    Untwisted case:

    Sage

        sage: NonSymmetricMacdonaldPolynomials("B2~").rho_prime()  # CHECKME
        3/2*e[0] + 1/2*e[1]
        sage: NonSymmetricMacdonaldPolynomials("B2~").rho_prime().parent()
        Coambient space of the Root system of type ['C', 2, 1]

    Python

        >>> from sage.all import *
        >>> NonSymmetricMacdonaldPolynomials("B2~").rho_prime()  # CHECKME
        3/2*e[0] + 1/2*e[1]
        >>> NonSymmetricMacdonaldPolynomials("B2~").rho_prime().parent()
        Coambient space of the Root system of type ['C', 2, 1]

    Twisted case:

    Sage

        sage: NonSymmetricMacdonaldPolynomials("B2~*").rho_prime()  # CHECKME
        2*e[0] + e[1]
        sage: NonSymmetricMacdonaldPolynomials("B2~*").rho_prime().parent()
        Ambient space of the Root system of type ['B', 2, 1]^*

    [Python]

        >>> from sage.all import *
        >>> NonSymmetricMacdonaldPolynomials("B2~*").rho_prime()  # CHECKME
        2*e[0] + e[1]
        >>> NonSymmetricMacdonaldPolynomials("B2~*").rho_prime().parent()
        Ambient space of the Root system of type ['B', 2, 1]^*

  seed(mu)

    Return \(E_\mu\) for \(\mu\) minuscule, i.e. in the fundamental alcove.

    INPUT:

    - `mu` – the index \(\mu\) of an eigenvector

    EXAMPLES:

    Sage

        sage: E = NonSymmetricMacdonaldPolynomials(["A",2,1])
        sage: omega = E.keys().fundamental_weights()
        sage: E.seed(omega[1])
        B[(1, 0, 0)]

    Python

        >>> from sage.all import *
        >>> E = NonSymmetricMacdonaldPolynomials(["A",Integer(2),Integer(1)])
        >>> omega = E.keys().fundamental_weights()
        >>> E.seed(omega[Integer(1)])
        B[(1, 0, 0)]

  symmetric_macdonald_polynomial(mu)

    Return the symmetric Macdonald polynomial indexed by \(\mu\).

    INPUT:

    - `mu` – a dominant weight \(\mu\)

    Warning

    The result is Weyl-symmetric only for Hecke parameters of the form \(q_1=v\) and \(q_2=-1/v\). In general the value of \(v\) below, should be the square root of \(-q_1/q_2\), but the use of \(q_1=t\) and \(q_2=-1\) results in nonintegral powers of \(t\).

    EXAMPLES:

    Sage

        sage: K = QQ['q,v,t'].fraction_field()
        sage: q,v,t = K.gens()
        sage: E = NonSymmetricMacdonaldPolynomials(['A',2,1], q, v, -1/v)
        sage: om = E.L0().fundamental_weights()
        sage: E.symmetric_macdonald_polynomial(om[2])                               # needs sage.libs.gap
        B[(1, 1, 0)] + B[(1, 0, 1)] + B[(0, 1, 1)]
        sage: E.symmetric_macdonald_polynomial(2*om[1])                             # needs sage.libs.gap
        ((q*v^2+v^2-q-1)/(q*v^2-1))*B[(1, 1, 0)]
        + ((q*v^2+v^2-q-1)/(q*v^2-1))*B[(1, 0, 1)] + B[(2, 0, 0)]
        + ((q*v^2+v^2-q-1)/(q*v^2-1))*B[(0, 1, 1)] + B[(0, 2, 0)] + B[(0, 0, 2)]
        sage: f = E.symmetric_macdonald_polynomial(E.L0()((2,1,0))); f              # needs sage.libs.gap
        ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(1, 1, 1)] + B[(1, 2, 0)]
        + B[(1, 0, 2)] + B[(2, 1, 0)] + B[(2, 0, 1)] + B[(0, 1, 2)] + B[(0, 2, 1)]

    Python

        >>> from sage.all import *
        >>> K = QQ['q,v,t'].fraction_field()
        >>> q,v,t = K.gens()
        >>> E = NonSymmetricMacdonaldPolynomials(['A',Integer(2),Integer(1)], q, v, -Integer(1)/v)
        >>> om = E.L0().fundamental_weights()
        >>> E.symmetric_macdonald_polynomial(om[Integer(2)])                               # needs sage.libs.gap
        B[(1, 1, 0)] + B[(1, 0, 1)] + B[(0, 1, 1)]
        >>> E.symmetric_macdonald_polynomial(Integer(2)*om[Integer(1)])                             # needs sage.libs.gap
        ((q*v^2+v^2-q-1)/(q*v^2-1))*B[(1, 1, 0)]
        + ((q*v^2+v^2-q-1)/(q*v^2-1))*B[(1, 0, 1)] + B[(2, 0, 0)]
        + ((q*v^2+v^2-q-1)/(q*v^2-1))*B[(0, 1, 1)] + B[(0, 2, 0)] + B[(0, 0, 2)]
        >>> f = E.symmetric_macdonald_polynomial(E.L0()((Integer(2),Integer(1),Integer(0)))); f              # needs sage.libs.gap
        ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(1, 1, 1)] + B[(1, 2, 0)]
        + B[(1, 0, 2)] + B[(2, 1, 0)] + B[(2, 0, 1)] + B[(0, 1, 2)] + B[(0, 2, 1)]

    We compare with the type \(A\) Macdonald polynomials coming from symmetric functions:

    Sage

        sage: # needs sage.combinat
        sage: P = SymmetricFunctions(K).macdonald().P()
        sage: g = P[2,1].expand(3); g
        x0^2*x1 + x0*x1^2 + x0^2*x2
        + (2*q*t^2 - q*t - q  + t^2 + t - 2)/(q*t^2 - 1)*x0*x1*x2
        + x1^2*x2 + x0*x2^2 + x1*x2^2
        sage: fe = f.expand(g.parent().gens()); fe                                  # needs sage.libs.gap
        x0^2*x1 + x0*x1^2 + x0^2*x2
        + (2*q*v^4 - q*v^2 - q + v^4 + v^2 - 2)/(q*v^4 - 1)*x0*x1*x2
        + x1^2*x2 + x0*x2^2 + x1*x2^2
        sage: g.map_coefficients(lambda x: x.subs(t=v*v)) == fe                     # needs sage.libs.gap
        True

        sage: E = NonSymmetricMacdonaldPolynomials(['C',3,1], q, v, -1/v)
        sage: om = E.L0().fundamental_weights()
        sage: E.symmetric_macdonald_polynomial(om[1]+om[2])
        B[(-2, -1, 0)] + B[(-2, 1, 0)] + B[(-2, 0, -1)] + B[(-2, 0, 1)]
        + ((4*q^3*v^14+2*q^2*v^14-2*q^3*v^12+2*q^2*v^12-2*q^3*v^10+q*v^12-5*q^2*v^10-5*q*v^4+q^2*v^2-2*v^4+2*q*v^2-2*v^2+2*q+4)/(q^3*v^14-q^2*v^10-q*v^4+1))*B[(-1, 0, 0)]
        + B[(-1, -2, 0)] + ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(-1, -1, -1)]
        + ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(-1, -1, 1)] + ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(-1, 1, -1)]
        + ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(-1, 1, 1)] + B[(-1, 2, 0)] + B[(-1, 0, -2)] + B[(-1, 0, 2)]
        + ((4*q^3*v^14+2*q^2*v^14-2*q^3*v^12+2*q^2*v^12-2*q^3*v^10+q*v^12-5*q^2*v^10-5*q*v^4+q^2*v^2-2*v^4+2*q*v^2-2*v^2+2*q+4)/(q^3*v^14-q^2*v^10-q*v^4+1))*B[(1, 0, 0)] + B[(1, -2, 0)]
        + ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(1, -1, -1)]
        + ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(1, -1, 1)]
        + ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(1, 1, -1)]
        + ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(1, 1, 1)] + B[(1, 2, 0)] + B[(1, 0, -2)] + B[(1, 0, 2)]
        + B[(2, -1, 0)] + B[(2, 1, 0)] + B[(2, 0, -1)] + B[(2, 0, 1)] + B[(0, -2, -1)] + B[(0, -2, 1)]
        - ((4*q^3*v^14+2*q^2*v^14-2*q^3*v^12+2*q^2*v^12-2*q^3*v^10+q*v^12-5*q^2*v^10-5*q*v^4+q^2*v^2-2*v^4+2*q*v^2-2*v^2+2*q+4)/(-q^3*v^14+q^2*v^10+q*v^4-1))*B[(0, -1, 0)]
        + B[(0, -1, -2)]
        + B[(0, -1, 2)]
        - ((4*q^3*v^14+2*q^2*v^14-2*q^3*v^12+2*q^2*v^12-2*q^3*v^10+q*v^12-5*q^2*v^10-5*q*v^4+q^2*v^2-2*v^4+2*q*v^2-2*v^2+2*q+4)/(-q^3*v^14+q^2*v^10+q*v^4-1))*B[(0, 1, 0)]
        + B[(0, 1, -2)] + B[(0, 1, 2)] + B[(0, 2, -1)] + B[(0, 2, 1)]
        + ((4*q^3*v^14+2*q^2*v^14-2*q^3*v^12+2*q^2*v^12-2*q^3*v^10+q*v^12-5*q^2*v^10-5*q*v^4+q^2*v^2-2*v^4+2*q*v^2-2*v^2+2*q+4)/(q^3*v^14-q^2*v^10-q*v^4+1))*B[(0, 0, -1)]
        + ((4*q^3*v^14+2*q^2*v^14-2*q^3*v^12+2*q^2*v^12-2*q^3*v^10+q*v^12-5*q^2*v^10-5*q*v^4+q^2*v^2-2*v^4+2*q*v^2-2*v^2+2*q+4)/(q^3*v^14-q^2*v^10-q*v^4+1))*B[(0, 0, 1)]

    [Python]

        >>> from sage.all import *
        >>> # needs sage.combinat
        >>> P = SymmetricFunctions(K).macdonald().P()
        >>> g = P[Integer(2),Integer(1)].expand(Integer(3)); g
        x0^2*x1 + x0*x1^2 + x0^2*x2
        + (2*q*t^2 - q*t - q  + t^2 + t - 2)/(q*t^2 - 1)*x0*x1*x2
        + x1^2*x2 + x0*x2^2 + x1*x2^2
        >>> fe = f.expand(g.parent().gens()); fe                                  # needs sage.libs.gap
        x0^2*x1 + x0*x1^2 + x0^2*x2
        + (2*q*v^4 - q*v^2 - q + v^4 + v^2 - 2)/(q*v^4 - 1)*x0*x1*x2
        + x1^2*x2 + x0*x2^2 + x1*x2^2
        >>> g.map_coefficients(lambda x: x.subs(t=v*v)) == fe                     # needs sage.libs.gap
        True

        >>> E = NonSymmetricMacdonaldPolynomials(['C',Integer(3),Integer(1)], q, v, -Integer(1)/v)
        >>> om = E.L0().fundamental_weights()
        >>> E.symmetric_macdonald_polynomial(om[Integer(1)]+om[Integer(2)])
        B[(-2, -1, 0)] + B[(-2, 1, 0)] + B[(-2, 0, -1)] + B[(-2, 0, 1)]
        + ((4*q^3*v^14+2*q^2*v^14-2*q^3*v^12+2*q^2*v^12-2*q^3*v^10+q*v^12-5*q^2*v^10-5*q*v^4+q^2*v^2-2*v^4+2*q*v^2-2*v^2+2*q+4)/(q^3*v^14-q^2*v^10-q*v^4+1))*B[(-1, 0, 0)]
        + B[(-1, -2, 0)] + ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(-1, -1, -1)]
        + ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(-1, -1, 1)] + ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(-1, 1, -1)]
        + ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(-1, 1, 1)] + B[(-1, 2, 0)] + B[(-1, 0, -2)] + B[(-1, 0, 2)]
        + ((4*q^3*v^14+2*q^2*v^14-2*q^3*v^12+2*q^2*v^12-2*q^3*v^10+q*v^12-5*q^2*v^10-5*q*v^4+q^2*v^2-2*v^4+2*q*v^2-2*v^2+2*q+4)/(q^3*v^14-q^2*v^10-q*v^4+1))*B[(1, 0, 0)] + B[(1, -2, 0)]
        + ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(1, -1, -1)]
        + ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(1, -1, 1)]
        + ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(1, 1, -1)]
        + ((2*q*v^4+v^4-q*v^2+v^2-q-2)/(q*v^4-1))*B[(1, 1, 1)] + B[(1, 2, 0)] + B[(1, 0, -2)] + B[(1, 0, 2)]
        + B[(2, -1, 0)] + B[(2, 1, 0)] + B[(2, 0, -1)] + B[(2, 0, 1)] + B[(0, -2, -1)] + B[(0, -2, 1)]
        - ((4*q^3*v^14+2*q^2*v^14-2*q^3*v^12+2*q^2*v^12-2*q^3*v^10+q*v^12-5*q^2*v^10-5*q*v^4+q^2*v^2-2*v^4+2*q*v^2-2*v^2+2*q+4)/(-q^3*v^14+q^2*v^10+q*v^4-1))*B[(0, -1, 0)]
        + B[(0, -1, -2)]
        + B[(0, -1, 2)]
        - ((4*q^3*v^14+2*q^2*v^14-2*q^3*v^12+2*q^2*v^12-2*q^3*v^10+q*v^12-5*q^2*v^10-5*q*v^4+q^2*v^2-2*v^4+2*q*v^2-2*v^2+2*q+4)/(-q^3*v^14+q^2*v^10+q*v^4-1))*B[(0, 1, 0)]
        + B[(0, 1, -2)] + B[(0, 1, 2)] + B[(0, 2, -1)] + B[(0, 2, 1)]
        + ((4*q^3*v^14+2*q^2*v^14-2*q^3*v^12+2*q^2*v^12-2*q^3*v^10+q*v^12-5*q^2*v^10-5*q*v^4+q^2*v^2-2*v^4+2*q*v^2-2*v^2+2*q+4)/(q^3*v^14-q^2*v^10-q*v^4+1))*B[(0, 0, -1)]
        + ((4*q^3*v^14+2*q^2*v^14-2*q^3*v^12+2*q^2*v^12-2*q^3*v^10+q*v^12-5*q^2*v^10-5*q*v^4+q^2*v^2-2*v^4+2*q*v^2-2*v^2+2*q+4)/(q^3*v^14-q^2*v^10-q*v^4+1))*B[(0, 0, 1)]

    An example for type \(G\):

    Sage

        sage: E = NonSymmetricMacdonaldPolynomials(['G',2,1], q, v, -1/v)
        sage: om = E.L0().fundamental_weights()
        sage: E.symmetric_macdonald_polynomial(2*om[1])
        ((3*q^6*v^22+3*q^5*v^22-3*q^6*v^20+q^4*v^22-4*q^5*v^20+q^4*v^18-q^5*v^16+q^3*v^18-2*q^4*v^16+q^5*v^14-q^3*v^16+q^4*v^14-4*q^4*v^12+q^2*v^14+q^5*v^10-8*q^3*v^12+4*q^4*v^10-4*q^2*v^12+8*q^3*v^10-q*v^12-q^4*v^8+4*q^2*v^10-q^2*v^8+q^3*v^6-q*v^8+2*q^2*v^6-q^3*v^4+q*v^6-q^2*v^4+4*q*v^2-q^2+3*v^2-3*q-3)/(q^6*v^22-q^5*v^20-q^4*v^12-q^3*v^12+q^3*v^10+q^2*v^10+q*v^2-1))*B[(0, 0, 0)]
        + ((q*v^2+v^2-q-1)/(q*v^2-1))*B[(-2, 1, 1)] + B[(-2, 2, 0)] + B[(-2, 0, 2)]
        - ((q*v^2+v^2-q-1)/(-q*v^2+1))*B[(-1, -1, 2)]
        + ((2*q^4*v^12+2*q^3*v^12-2*q^4*v^10-2*q^3*v^10+q^2*v^8-q^3*v^6+q*v^8-2*q^2*v^6+q^3*v^4-q*v^6+q^2*v^4-2*q*v^2-2*v^2+2*q+2)/(q^4*v^12-q^3*v^10-q*v^2+1))*B[(-1, 1, 0)]
        - ((q*v^2+v^2-q-1)/(-q*v^2+1))*B[(-1, 2, -1)]
        + ((2*q^4*v^12+2*q^3*v^12-2*q^4*v^10-2*q^3*v^10+q^2*v^8-q^3*v^6+q*v^8-2*q^2*v^6+q^3*v^4-q*v^6+q^2*v^4-2*q*v^2-2*v^2+2*q+2)/(q^4*v^12-q^3*v^10-q*v^2+1))*B[(-1, 0, 1)]
        - ((q*v^2+v^2-q-1)/(-q*v^2+1))*B[(1, -2, 1)]
        - ((2*q^4*v^12+2*q^3*v^12-2*q^4*v^10-2*q^3*v^10+q^2*v^8-q^3*v^6+q*v^8-2*q^2*v^6+q^3*v^4-q*v^6+q^2*v^4-2*q*v^2-2*v^2+2*q+2)/(-q^4*v^12+q^3*v^10+q*v^2-1))*B[(1, -1, 0)]
        - ((q*v^2+v^2-q-1)/(-q*v^2+1))*B[(1, 1, -2)]
        - ((2*q^4*v^12+2*q^3*v^12-2*q^4*v^10-2*q^3*v^10+q^2*v^8-q^3*v^6+q*v^8-2*q^2*v^6+q^3*v^4-q*v^6+q^2*v^4-2*q*v^2-2*v^2+2*q+2)/(-q^4*v^12+q^3*v^10+q*v^2-1))*B[(1, 0, -1)]
        + B[(2, -2, 0)] + ((q*v^2+v^2-q-1)/(q*v^2-1))*B[(2, -1, -1)] + B[(2, 0, -2)] + B[(0, -2, 2)]
        - ((2*q^4*v^12+2*q^3*v^12-2*q^4*v^10-2*q^3*v^10+q^2*v^8-q^3*v^6+q*v^8-2*q^2*v^6+q^3*v^4-q*v^6+q^2*v^4-2*q*v^2-2*v^2+2*q+2)/(-q^4*v^12+q^3*v^10+q*v^2-1))*B[(0, -1, 1)]
        + ((2*q^4*v^12+2*q^3*v^12-2*q^4*v^10-2*q^3*v^10+q^2*v^8-q^3*v^6+q*v^8-2*q^2*v^6+q^3*v^4-q*v^6+q^2*v^4-2*q*v^2-2*v^2+2*q+2)/(q^4*v^12-q^3*v^10-q*v^2+1))*B[(0, 1, -1)]
        + B[(0, 2, -2)]

    Python

        >>> from sage.all import *
        >>> E = NonSymmetricMacdonaldPolynomials(['G',Integer(2),Integer(1)], q, v, -Integer(1)/v)
        >>> om = E.L0().fundamental_weights()
        >>> E.symmetric_macdonald_polynomial(Integer(2)*om[Integer(1)])
        ((3*q^6*v^22+3*q^5*v^22-3*q^6*v^20+q^4*v^22-4*q^5*v^20+q^4*v^18-q^5*v^16+q^3*v^18-2*q^4*v^16+q^5*v^14-q^3*v^16+q^4*v^14-4*q^4*v^12+q^2*v^14+q^5*v^10-8*q^3*v^12+4*q^4*v^10-4*q^2*v^12+8*q^3*v^10-q*v^12-q^4*v^8+4*q^2*v^10-q^2*v^8+q^3*v^6-q*v^8+2*q^2*v^6-q^3*v^4+q*v^6-q^2*v^4+4*q*v^2-q^2+3*v^2-3*q-3)/(q^6*v^22-q^5*v^20-q^4*v^12-q^3*v^12+q^3*v^10+q^2*v^10+q*v^2-1))*B[(0, 0, 0)]
        + ((q*v^2+v^2-q-1)/(q*v^2-1))*B[(-2, 1, 1)] + B[(-2, 2, 0)] + B[(-2, 0, 2)]
        - ((q*v^2+v^2-q-1)/(-q*v^2+1))*B[(-1, -1, 2)]
        + ((2*q^4*v^12+2*q^3*v^12-2*q^4*v^10-2*q^3*v^10+q^2*v^8-q^3*v^6+q*v^8-2*q^2*v^6+q^3*v^4-q*v^6+q^2*v^4-2*q*v^2-2*v^2+2*q+2)/(q^4*v^12-q^3*v^10-q*v^2+1))*B[(-1, 1, 0)]
        - ((q*v^2+v^2-q-1)/(-q*v^2+1))*B[(-1, 2, -1)]
        + ((2*q^4*v^12+2*q^3*v^12-2*q^4*v^10-2*q^3*v^10+q^2*v^8-q^3*v^6+q*v^8-2*q^2*v^6+q^3*v^4-q*v^6+q^2*v^4-2*q*v^2-2*v^2+2*q+2)/(q^4*v^12-q^3*v^10-q*v^2+1))*B[(-1, 0, 1)]
        - ((q*v^2+v^2-q-1)/(-q*v^2+1))*B[(1, -2, 1)]
        - ((2*q^4*v^12+2*q^3*v^12-2*q^4*v^10-2*q^3*v^10+q^2*v^8-q^3*v^6+q*v^8-2*q^2*v^6+q^3*v^4-q*v^6+q^2*v^4-2*q*v^2-2*v^2+2*q+2)/(-q^4*v^12+q^3*v^10+q*v^2-1))*B[(1, -1, 0)]
        - ((q*v^2+v^2-q-1)/(-q*v^2+1))*B[(1, 1, -2)]
        - ((2*q^4*v^12+2*q^3*v^12-2*q^4*v^10-2*q^3*v^10+q^2*v^8-q^3*v^6+q*v^8-2*q^2*v^6+q^3*v^4-q*v^6+q^2*v^4-2*q*v^2-2*v^2+2*q+2)/(-q^4*v^12+q^3*v^10+q*v^2-1))*B[(1, 0, -1)]
        + B[(2, -2, 0)] + ((q*v^2+v^2-q-1)/(q*v^2-1))*B[(2, -1, -1)] + B[(2, 0, -2)] + B[(0, -2, 2)]
        - ((2*q^4*v^12+2*q^3*v^12-2*q^4*v^10-2*q^3*v^10+q^2*v^8-q^3*v^6+q*v^8-2*q^2*v^6+q^3*v^4-q*v^6+q^2*v^4-2*q*v^2-2*v^2+2*q+2)/(-q^4*v^12+q^3*v^10+q*v^2-1))*B[(0, -1, 1)]
        + ((2*q^4*v^12+2*q^3*v^12-2*q^4*v^10-2*q^3*v^10+q^2*v^8-q^3*v^6+q*v^8-2*q^2*v^6+q^3*v^4-q*v^6+q^2*v^4-2*q*v^2-2*v^2+2*q+2)/(q^4*v^12-q^3*v^10-q*v^2+1))*B[(0, 1, -1)]
        + B[(0, 2, -2)]

  twist(mu, i)

    Act by \(s_i\) on the affine weight \(\mu\).

    This calls `simple_reflection`; which is semantically the same as the default implementation.

    EXAMPLES:

    Sage

        sage: # needs sage.libs.gap
        sage: W = WeylGroup(["B",3])
        sage: W.element_class._repr_ = lambda x: "".join(str(i)
        ....:                                            for i in x.reduced_word())
        sage: K = QQ['q1,q2']
        sage: q1, q2 = K.gens()
        sage: KW = W.algebra(K)
        sage: T = KW.demazure_lusztig_operators(q1, q2, affine=True)
        sage: E = T.Y_eigenvectors()
        sage: w = W.an_element(); w
        123
        sage: E.twist(w,1)
        1231

    Python

        >>> from sage.all import *
        >>> # needs sage.libs.gap
        >>> W = WeylGroup(["B",Integer(3)])
        >>> W.element_class._repr_ = lambda x: "".join(str(i)
        ...                                            for i in x.reduced_word())
        >>> K = QQ['q1,q2']
        >>> q1, q2 = K.gens()
        >>> KW = W.algebra(K)
        >>> T = KW.demazure_lusztig_operators(q1, q2, affine=True)
        >>> E = T.Y_eigenvectors()
        >>> w = W.an_element(); w
        123
        >>> E.twist(w,Integer(1))
        1231