Quantum-valued polynomial rings - Polynomials

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

# Quantum-valued polynomial rings

This provides a \(q\)-analogue of the `IntegerValuedPolynomialRing`.

AUTHORS:

- Frédéric Chapoton (2024-03): Initial version

class sage.rings.polynomial.q_integer_valued_polynomials.QuantumValuedPolynomialRing(R, q)

  Bases: `UniqueRepresentation`, `Parent`

  The quantum-valued polynomial ring over a base ring.

  Quantum-valued polynomial rings are commutative and associative algebras, with a basis indexed by nonnegative integers.

  The elements are polynomials in one variable \(x\) with coefficients in the field of rational functions in \(q\), such that the value at every nonegative \(q\)-integer is a polynomial in \(q\).

  This algebra is endowed with two bases, named `B` or `Binomial` and `S` or `Shifted`.

  INPUT:

  - `R` – commutative ring

  - `q` – optional variable

  There are two possible input formats:

  - If the argument `q` is not given, then the ring `R` is taken as a base ring and the ring of Laurent polynomials in \(q\) over `R` is built and used.

  - If the argument `q` is given, then it should belong to the ring `R` and be invertible in this ring.

  EXAMPLES:

  Sage

      sage: F = QuantumValuedPolynomialRing(QQ).S(); F
      Quantum-Valued Polynomial Ring over Rational Field
      in the shifted basis

      sage: F.gen()
      S[1]

      sage: S = QuantumValuedPolynomialRing(ZZ); S
      Quantum-Valued Polynomial Ring over Integer Ring
      sage: S.base_ring()
      Univariate Laurent Polynomial Ring in q over Integer Ring

  Python

      >>> from sage.all import *
      >>> F = QuantumValuedPolynomialRing(QQ).S(); F
      Quantum-Valued Polynomial Ring over Rational Field
      in the shifted basis

      >>> F.gen()
      S[1]

      >>> S = QuantumValuedPolynomialRing(ZZ); S
      Quantum-Valued Polynomial Ring over Integer Ring
      >>> S.base_ring()
      Univariate Laurent Polynomial Ring in q over Integer Ring

  Quantum-valued polynomial rings commute with their base ring:

  Sage

      sage: K = QuantumValuedPolynomialRing(QQ).S()
      sage: a = K.gen()
      sage: c = K.monomial(2)

  [Python]

      >>> from sage.all import *
      >>> K = QuantumValuedPolynomialRing(QQ).S()
      >>> a = K.gen()
      >>> c = K.monomial(Integer(2))

  Quantum-valued polynomial rings are commutative:

  Sage

      sage: c^3 * a == c * a * c * c
      True

  Python

      >>> from sage.all import *
      >>> c**Integer(3) * a == c * a * c * c
      True

  We can also manipulate elements in the basis and coerce elements from our base field:

  Sage

      sage: F = QuantumValuedPolynomialRing(QQ).S()
      sage: B = F.basis()
      sage: B[2] * B[3]
      (q^-5+q^-4+q^-3)*S[3] - (q^-6+2*q^-5+3*q^-4+3*q^-3+2*q^-2+q^-1)*S[4]
      + (q^-6+q^-5+2*q^-4+2*q^-3+2*q^-2+q^-1+1)*S[5]
      sage: 1 - B[2] * B[2] / 2
      S[0] - (1/2*q^-3)*S[2] + (1/2*q^-4+q^-3+q^-2+1/2*q^-1)*S[3]
      - (1/2*q^-4+1/2*q^-3+q^-2+1/2*q^-1+1/2)*S[4]

  [Python]

      >>> from sage.all import *
      >>> F = QuantumValuedPolynomialRing(QQ).S()
      >>> B = F.basis()
      >>> B[Integer(2)] * B[Integer(3)]
      (q^-5+q^-4+q^-3)*S[3] - (q^-6+2*q^-5+3*q^-4+3*q^-3+2*q^-2+q^-1)*S[4]
      + (q^-6+q^-5+2*q^-4+2*q^-3+2*q^-2+q^-1+1)*S[5]
      >>> Integer(1) - B[Integer(2)] * B[Integer(2)] / Integer(2)
      S[0] - (1/2*q^-3)*S[2] + (1/2*q^-4+q^-3+q^-2+1/2*q^-1)*S[3]
      - (1/2*q^-4+1/2*q^-3+q^-2+1/2*q^-1+1/2)*S[4]

  B

    alias of `Binomial`

  class Bases(parent_with_realization)

    Bases: `Category_realization_of_parent`

    class ElementMethods

      Bases: `object`

      polynomial()

        Convert to a polynomial in \(x\).

        EXAMPLES:

        Sage

            sage: F = QuantumValuedPolynomialRing(ZZ).S()
            sage: S = F.gen()
            sage: (S+1).polynomial()
            q*x + 2

            sage: F = QuantumValuedPolynomialRing(ZZ).B()
            sage: B = F.gen()
            sage: (B+1).polynomial()
            x + 1

        Python

            >>> from sage.all import *
            >>> F = QuantumValuedPolynomialRing(ZZ).S()
            >>> S = F.gen()
            >>> (S+Integer(1)).polynomial()
            q*x + 2

            >>> F = QuantumValuedPolynomialRing(ZZ).B()
            >>> B = F.gen()
            >>> (B+Integer(1)).polynomial()
            x + 1

      shift(j=1)

        Shift all indices by \(j\).

        INPUT:

        - \(j\) – integer (default 1)

        In the binomial basis, the shift by 1 corresponds to a summation operator from \(0\) to \(x\).

        EXAMPLES:

        Sage

            sage: F = QuantumValuedPolynomialRing(ZZ).S()
            sage: B = F.gen()
            sage: (B+1).shift()
            S[1] + S[2]

        Python

            >>> from sage.all import *
            >>> F = QuantumValuedPolynomialRing(ZZ).S()
            >>> B = F.gen()
            >>> (B+Integer(1)).shift()
            S[1] + S[2]

      sum_of_coefficients()

        Return the sum of coefficients.

        In the shifted basis, this is the evaluation at \(x=0\).

        EXAMPLES:

        Sage

            sage: F = QuantumValuedPolynomialRing(ZZ).S()
            sage: B = F.basis()
            sage: (B[2]*B[4]).sum_of_coefficients()
            1

        Python

            >>> from sage.all import *
            >>> F = QuantumValuedPolynomialRing(ZZ).S()
            >>> B = F.basis()
            >>> (B[Integer(2)]*B[Integer(4)]).sum_of_coefficients()
            1

    class ParentMethods

      Bases: `object`

      algebra_generators()

        Return the generators of this algebra.

        EXAMPLES:

        Sage

            sage: A = QuantumValuedPolynomialRing(ZZ).S(); A
            Quantum-Valued Polynomial Ring over Integer Ring
            in the shifted basis
            sage: A.algebra_generators()
            Family (S[1],)

        Python

            >>> from sage.all import *
            >>> A = QuantumValuedPolynomialRing(ZZ).S(); A
            Quantum-Valued Polynomial Ring over Integer Ring
            in the shifted basis
            >>> A.algebra_generators()
            Family (S[1],)

      degree_on_basis(m)

        Return the degree of the basis element indexed by `m`.

        EXAMPLES:

        Sage

            sage: A = QuantumValuedPolynomialRing(QQ).S()
            sage: A.degree_on_basis(4)
            4

        Python

            >>> from sage.all import *
            >>> A = QuantumValuedPolynomialRing(QQ).S()
            >>> A.degree_on_basis(Integer(4))
            4

      from_polynomial(p)

        Convert a polynomial into the ring of quantum-valued polynomials.

        This raises a `ValueError` if this is not possible.

        INPUT:

        - `p` – a polynomial in `x` with coefficients in `QQ(q)`

        EXAMPLES:

        Sage

            sage: A = QuantumValuedPolynomialRing(ZZ).S()
            sage: S = A.basis()
            sage: A.from_polynomial((S[1]).polynomial())
            S[1]
            sage: A.from_polynomial((S[2]+2*S[3]).polynomial())
            S[2] + 2*S[3]

            sage: A = QuantumValuedPolynomialRing(ZZ).B()
            sage: B = A.basis()
            sage: A.from_polynomial((B[1]).polynomial())
            B[1]
            sage: A.from_polynomial((B[2]+2*B[3]).polynomial())
            B[2] + 2*B[3]

        Python

            >>> from sage.all import *
            >>> A = QuantumValuedPolynomialRing(ZZ).S()
            >>> S = A.basis()
            >>> A.from_polynomial((S[Integer(1)]).polynomial())
            S[1]
            >>> A.from_polynomial((S[Integer(2)]+Integer(2)*S[Integer(3)]).polynomial())
            S[2] + 2*S[3]

            >>> A = QuantumValuedPolynomialRing(ZZ).B()
            >>> B = A.basis()
            >>> A.from_polynomial((B[Integer(1)]).polynomial())
            B[1]
            >>> A.from_polynomial((B[Integer(2)]+Integer(2)*B[Integer(3)]).polynomial())
            B[2] + 2*B[3]

      gen(i=0)

        Return the generator of the algebra.

        The optional argument is ignored.

        EXAMPLES:

        Sage

            sage: F = QuantumValuedPolynomialRing(ZZ).S()
            sage: F.gen()
            S[1]

        Python

            >>> from sage.all import *
            >>> F = QuantumValuedPolynomialRing(ZZ).S()
            >>> F.gen()
            S[1]

      gens()

        alias of `algebra_generators()`.

      ground_ring()

        Return the ring of coefficients.

        This ring is not supposed to contain the variable \(q\).

        EXAMPLES:

        Sage

            sage: A = QuantumValuedPolynomialRing(QQ).S()
            sage: A.ground_ring()
            Rational Field

        Python

            >>> from sage.all import *
            >>> A = QuantumValuedPolynomialRing(QQ).S()
            >>> A.ground_ring()
            Rational Field

      one_basis()

        Return the number 0, which index the unit of this algebra.

        EXAMPLES:

        Sage

            sage: A = QuantumValuedPolynomialRing(QQ).S()
            sage: A.one_basis()
            0
            sage: A.one()
            S[0]

        Python

            >>> from sage.all import *
            >>> A = QuantumValuedPolynomialRing(QQ).S()
            >>> A.one_basis()
            0
            >>> A.one()
            S[0]

      q()

        Return the variable \(q\).

        EXAMPLES:

        Sage

            sage: A = QuantumValuedPolynomialRing(QQ).S()
            sage: A.q()
            q

        Python

            >>> from sage.all import *
            >>> A = QuantumValuedPolynomialRing(QQ).S()
            >>> A.q()
            q

    super_categories()

      Return the super-categories of `self`.

      EXAMPLES:

      Sage

          sage: A = QuantumValuedPolynomialRing(QQ); A
          Quantum-Valued Polynomial Ring over Rational Field
          sage: C = A.Bases(); C
          Category of bases of Quantum-Valued Polynomial Ring
          over Rational Field
          sage: C.super_categories()
          [Category of realizations of Quantum-Valued Polynomial Ring
           over Rational Field,
           Join of Category of algebras with basis
           over Univariate Laurent Polynomial Ring in q over Rational Field and
           Category of filtered algebras
           over Univariate Laurent Polynomial Ring in q over Rational Field and
           Category of commutative algebras
           over Univariate Laurent Polynomial Ring in q over Rational Field and
           Category of realizations of unital magmas]

      Python

          >>> from sage.all import *
          >>> A = QuantumValuedPolynomialRing(QQ); A
          Quantum-Valued Polynomial Ring over Rational Field
          >>> C = A.Bases(); C
          Category of bases of Quantum-Valued Polynomial Ring
          over Rational Field
          >>> C.super_categories()
          [Category of realizations of Quantum-Valued Polynomial Ring
           over Rational Field,
           Join of Category of algebras with basis
           over Univariate Laurent Polynomial Ring in q over Rational Field and
           Category of filtered algebras
           over Univariate Laurent Polynomial Ring in q over Rational Field and
           Category of commutative algebras
           over Univariate Laurent Polynomial Ring in q over Rational Field and
           Category of realizations of unital magmas]

  class Binomial(A)

    Bases: `CombinatorialFreeModule`, `BindableClass`

    The quantum-valued polynomial ring in the binomial basis.

    The basis used here is given by \(B[i] = \genfrac{[}{]}{0pt}{}{x}{i}_q\) for \(i \in \NN\).

    Assuming \(n_1 \leq n_2\), the product of two monomials \(B[n_1] \cdot B[n_2]\) is given by the sum

    \[\sum_{k=0}^{n_1} q^{(k-n_1)(k-n_2)} \genfrac{[}{]}{0pt}{}{n_1}{k}_q \genfrac{[}{]}{0pt}{}{n_1+n_2-k}{n_1}_q B[n_1 + n_2 - k].\]
    class Element

      Bases: `IndexedFreeModuleElement`

      variable_shift(k=1)

        Return the image by the shift of variables.

        On polynomials, the action for \(k=1\) is the shift on variables \(x \mapsto 1 + qx\).

        This implementation follows formula (5.5) in [HaHo2017].

        INPUT:

        - \(k\) – nonnegative integer (default: 1)

        EXAMPLES:

        Sage

            sage: A = QuantumValuedPolynomialRing(ZZ).B()
            sage: B = A.basis()
            sage: B[5].variable_shift()
            B[4] + q^5*B[5]

        Python

            >>> from sage.all import *
            >>> A = QuantumValuedPolynomialRing(ZZ).B()
            >>> B = A.basis()
            >>> B[Integer(5)].variable_shift()
            B[4] + q^5*B[5]

    product_on_basis(n1, n2)

      Return the product of basis elements `n1` and `n2`.

      INPUT:

      - `n1`, `n2` – integers

      The formula is taken from Theorem 3.4 in [HaHo2017].

      EXAMPLES:

      Sage

          sage: A = QuantumValuedPolynomialRing(QQ).B()
          sage: A.product_on_basis(0, 1)
          B[1]

      Python

          >>> from sage.all import *
          >>> A = QuantumValuedPolynomialRing(QQ).B()
          >>> A.product_on_basis(Integer(0), Integer(1))
          B[1]

  S

    alias of `Shifted`

  class Shifted(A)

    Bases: `CombinatorialFreeModule`, `BindableClass`

    The quantum-valued polynomial ring in the shifted basis.

    The basis used here is given by \(S[i] = \genfrac{[}{]}{0pt}{}{i+x}{i}_q\) for \(i \in \NN\).

    Assuming \(n_1 \leq n_2\), the product of two monomials \(S[n_1] \cdot S[n_2]\) is given by the sum

    \[\sum_{k=0}^{n_1} (-1)^k q^{\binom{k}{2} - n_1 * n_2} \genfrac{[}{]}{0pt}{}{n_1}{k}_q \genfrac{[}{]}{0pt}{}{n_1+n_2-k}{n_1}_q S[n_1 + n_2 - k].\]
    class Element

      Bases: `IndexedFreeModuleElement`

      derivative_at_minus_one()

        Return the ‘derivative’ at -1.

        See also

        `umbra()`

        EXAMPLES:

        Sage

            sage: F = QuantumValuedPolynomialRing(ZZ).S()
            sage: B = F.gen()
            sage: (B+1).derivative_at_minus_one()
            1

        Python

            >>> from sage.all import *
            >>> F = QuantumValuedPolynomialRing(ZZ).S()
            >>> B = F.gen()
            >>> (B+Integer(1)).derivative_at_minus_one()
            1

      fraction()

        Return the generating series of values as a fraction.

        See also

        `h_vector()`, `h_polynomial()`

        EXAMPLES:

        Sage

            sage: A = QuantumValuedPolynomialRing(QQ).S()
            sage: ex = A.basis()[4]
            sage: ex.fraction().factor()
            (-1) * (t - 1)^-1 * (q*t - 1)^-1 * (q^2*t - 1)^-1 * (q^3*t - 1)^-1 * (q^4*t - 1)^-1

            sage: q = polygen(QQ,'q')
            sage: x = polygen(q.parent(), 'x')
            sage: ex = A.from_polynomial((1+q*x)**3)
            sage: ex.fraction().factor()
            (t - 1)^-1 * (q*t - 1)^-1 * (q^2*t - 1)^-1 * (q^3*t - 1)^-1 * (q^3*t^2 + 2*q^2*t + 2*q*t + 1)
            sage: ex.fraction().numerator()
            q^3*t^2 + 2*q^2*t + 2*q*t + 1

        Python

            >>> from sage.all import *
            >>> A = QuantumValuedPolynomialRing(QQ).S()
            >>> ex = A.basis()[Integer(4)]
            >>> ex.fraction().factor()
            (-1) * (t - 1)^-1 * (q*t - 1)^-1 * (q^2*t - 1)^-1 * (q^3*t - 1)^-1 * (q^4*t - 1)^-1

            >>> q = polygen(QQ,'q')
            >>> x = polygen(q.parent(), 'x')
            >>> ex = A.from_polynomial((Integer(1)+q*x)**Integer(3))
            >>> ex.fraction().factor()
            (t - 1)^-1 * (q*t - 1)^-1 * (q^2*t - 1)^-1 * (q^3*t - 1)^-1 * (q^3*t^2 + 2*q^2*t + 2*q*t + 1)
            >>> ex.fraction().numerator()
            q^3*t^2 + 2*q^2*t + 2*q*t + 1

      h_polynomial()

        Return the \(h\)-vector as a polynomial.

        See also

        `h_vector()`, `fraction()`

        EXAMPLES:

        Sage

            sage: A = QuantumValuedPolynomialRing(ZZ).S()
            sage: q = polygen(ZZ,'q')
            sage: x = polygen(q.parent(),'x')
            sage: ex = A.from_polynomial((1+q*x)**3)
            sage: ex.h_polynomial()
            z^3 + (2*q + 2*q^2)*z^2 + q^3*z

        Python

            >>> from sage.all import *
            >>> A = QuantumValuedPolynomialRing(ZZ).S()
            >>> q = polygen(ZZ,'q')
            >>> x = polygen(q.parent(),'x')
            >>> ex = A.from_polynomial((Integer(1)+q*x)**Integer(3))
            >>> ex.h_polynomial()
            z^3 + (2*q + 2*q^2)*z^2 + q^3*z

      h_vector()

        Return the numerator of the generating series of values.

        If `self` is an Ehrhart polynomial, this is the h-vector.

        See also

        `h_polynomial()`, `fraction()`

        EXAMPLES:

        Sage

            sage: A = QuantumValuedPolynomialRing(ZZ).S()
            sage: ex = A.basis()[4]
            sage: ex.h_vector()
            (0, 0, 0, 0, 1)

            sage: q = polygen(QQ,'q')
            sage: x = polygen(q.parent(),'x')
            sage: ex = A.from_polynomial((1+q*x)**3)
            sage: ex.h_vector()
            (0, q^3, 2*q + 2*q^2, 1)

        Python

            >>> from sage.all import *
            >>> A = QuantumValuedPolynomialRing(ZZ).S()
            >>> ex = A.basis()[Integer(4)]
            >>> ex.h_vector()
            (0, 0, 0, 0, 1)

            >>> q = polygen(QQ,'q')
            >>> x = polygen(q.parent(),'x')
            >>> ex = A.from_polynomial((Integer(1)+q*x)**Integer(3))
            >>> ex.h_vector()
            (0, q^3, 2*q + 2*q^2, 1)

      umbra()

        Return the Bernoulli umbra.

        This is the derivative at \(-1\) of the shift by one.

        This is related to Carlitz’s \(q\)-Bernoulli numbers.

        See also

        `derivative_at_minus_one()`

        EXAMPLES:

        Sage

            sage: F = QuantumValuedPolynomialRing(ZZ).S()
            sage: B = F.gen()
            sage: (B+1).umbra()
            (q + 2)/(q + 1)

        Python

            >>> from sage.all import *
            >>> F = QuantumValuedPolynomialRing(ZZ).S()
            >>> B = F.gen()
            >>> (B+Integer(1)).umbra()
            (q + 2)/(q + 1)

      variable_shift(k=1)

        Return the image by the shift on variables.

        The shift is the substitution operator

        \[x \mapsto q x + 1.\]

        INPUT:

        - \(k\) – integer (default: 1)

        EXAMPLES:

        Sage

            sage: A = QuantumValuedPolynomialRing(ZZ).S()
            sage: S = A.basis()
            sage: S[5].variable_shift()
            S[0] + q*S[1] + q^2*S[2] + q^3*S[3] + q^4*S[4] + q^5*S[5]

            sage: S[5].variable_shift(-1)
            -(q^-5)*S[4] + (q^-5)*S[5]

        Python

            >>> from sage.all import *
            >>> A = QuantumValuedPolynomialRing(ZZ).S()
            >>> S = A.basis()
            >>> S[Integer(5)].variable_shift()
            S[0] + q*S[1] + q^2*S[2] + q^3*S[3] + q^4*S[4] + q^5*S[5]

            >>> S[Integer(5)].variable_shift(-Integer(1))
            -(q^-5)*S[4] + (q^-5)*S[5]

    from_h_vector(hv)

      Convert from some \(h\)-vector.

      EXAMPLES:

      Sage

          sage: A = QuantumValuedPolynomialRing(ZZ).S()
          sage: B = A.basis()
          sage: ex = B[2] + B[3]
          sage: A.from_h_vector(ex.h_vector())
          S[2] + S[3]

          sage: q = A.base_ring().gen()
          sage: ex = B[2] + q*B[3]
          sage: A.from_h_vector(ex.h_vector())
          S[2] + q*S[3]

      Python

          >>> from sage.all import *
          >>> A = QuantumValuedPolynomialRing(ZZ).S()
          >>> B = A.basis()
          >>> ex = B[Integer(2)] + B[Integer(3)]
          >>> A.from_h_vector(ex.h_vector())
          S[2] + S[3]

          >>> q = A.base_ring().gen()
          >>> ex = B[Integer(2)] + q*B[Integer(3)]
          >>> A.from_h_vector(ex.h_vector())
          S[2] + q*S[3]

    product_on_basis(n1, n2)

      Return the product of basis elements `n1` and `n2`.

      INPUT:

      - `n1`, `n2` – integers

      EXAMPLES:

      Sage

          sage: A = QuantumValuedPolynomialRing(QQ).S()
          sage: A.product_on_basis(0, 1)
          S[1]

      Python

          >>> from sage.all import *
          >>> A = QuantumValuedPolynomialRing(QQ).S()
          >>> A.product_on_basis(Integer(0), Integer(1))
          S[1]

  a_realization()

    Return a default realization.

    The Shifted realization is chosen.

    EXAMPLES:

    Sage

        sage: QuantumValuedPolynomialRing(QQ).a_realization()
        Quantum-Valued Polynomial Ring over Rational Field
        in the shifted basis

    Python

        >>> from sage.all import *
        >>> QuantumValuedPolynomialRing(QQ).a_realization()
        Quantum-Valued Polynomial Ring over Rational Field
        in the shifted basis

sage.rings.polynomial.q_integer_valued_polynomials.q_binomial_x(m, n, q=None)

  Return a \(q\)-analogue of `binomial(m + x, n)`.

  When evaluated at the \(q\)-integer \([k]_q\), this gives the usual \(q\)-binomial coefficient \([m + k, n]_q\).

  INPUT:

  - `m` and `n` – positive integers

  - `q` – optional variable

  EXAMPLES:

  Sage

      sage: from sage.combinat.q_analogues import q_int
      sage: from sage.rings.polynomial.q_integer_valued_polynomials import q_binomial_x, q_int_x
      sage: q_binomial_x(4,2)(0) == q_binomial(4,2)
      True
      sage: q_binomial_x(3,2)(1) == q_binomial(4,2)
      True
      sage: q_binomial_x(3,1) == q_int_x(4)
      True
      sage: q_binomial_x(2,0).parent()
      Univariate Polynomial Ring in x over Fraction Field of
      Univariate Polynomial Ring in q over Integer Ring

  Python

      >>> from sage.all import *
      >>> from sage.combinat.q_analogues import q_int
      >>> from sage.rings.polynomial.q_integer_valued_polynomials import q_binomial_x, q_int_x
      >>> q_binomial_x(Integer(4),Integer(2))(Integer(0)) == q_binomial(Integer(4),Integer(2))
      True
      >>> q_binomial_x(Integer(3),Integer(2))(Integer(1)) == q_binomial(Integer(4),Integer(2))
      True
      >>> q_binomial_x(Integer(3),Integer(1)) == q_int_x(Integer(4))
      True
      >>> q_binomial_x(Integer(2),Integer(0)).parent()
      Univariate Polynomial Ring in x over Fraction Field of
      Univariate Polynomial Ring in q over Integer Ring

sage.rings.polynomial.q_integer_valued_polynomials.q_int_x(n, q=None)

  Return the interpolating polynomial of \(q\)-integers.

  INPUT:

  - `n` – a positive integer

  - `q` – optional variable

  EXAMPLES:

  Sage

      sage: from sage.rings.polynomial.q_integer_valued_polynomials import q_int_x
      sage: q_int_x(3)
      q^2*x + q + 1

  Python

      >>> from sage.all import *
      >>> from sage.rings.polynomial.q_integer_valued_polynomials import q_int_x
      >>> q_int_x(Integer(3))
      q^2*x + q + 1