ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 08 Oct 2014 11:59:08 +0200Vector over a polynomial ringhttps://ask.sagemath.org/question/24434/vector-over-a-polynomial-ring/In Sage 6.3 (both command line and notebook), I tried to define a vector over Q[X] as follows
R = PolynomialRing(QQ,'x')
X = polygen(R)
a, b = X^4-1, X-1
vec = vector(R,[a, b])
This produces an error
TypeError: not a constant polynomial
By contrast, the following works:
sage: vec = vector(R,[[a],[b]])
sage: vec
(x^4 - 1, x - 1)
Is this a bug or could someone explain me why?Wed, 08 Oct 2014 11:23:52 +0200https://ask.sagemath.org/question/24434/vector-over-a-polynomial-ring/Answer by tmonteil for <p>In Sage 6.3 (both command line and notebook), I tried to define a vector over Q[X] as follows</p>
<pre><code>R = PolynomialRing(QQ,'x')
X = polygen(R)
a, b = X^4-1, X-1
vec = vector(R,[a, b])
</code></pre>
<p>This produces an error</p>
<pre><code>TypeError: not a constant polynomial
</code></pre>
<p>By contrast, the following works:</p>
<pre><code>sage: vec = vector(R,[[a],[b]])
sage: vec
(x^4 - 1, x - 1)
</code></pre>
<p>Is this a bug or could someone explain me why?</p>
https://ask.sagemath.org/question/24434/vector-over-a-polynomial-ring/?answer=24437#post-id-24437Some hints:
Look at the documentation of ``polygen``:
sage: X = polygen?
Look at the parent of ``X`` (and ``a``):
sage: X.parent()
sage: a.parent()
sage: a.parent() == R
sage: X.base_ring()
In your example, replace
sage: X = polygen(R)
by
sage: X = R.gen()
And redo ever test to understand where your previous ``X`` was living and why. Do not hesitate to ask if you need more details.
Wed, 08 Oct 2014 11:59:08 +0200https://ask.sagemath.org/question/24434/vector-over-a-polynomial-ring/?answer=24437#post-id-24437