ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 04 Jan 2017 12:17:25 -0600Lifting a matrix from $\mathbb{Q}[Y]/(Y-1)$https://ask.sagemath.org/question/35555/lifting-a-matrix-from-mathbbqyy-1/I have a matrix in $\mathbb{Q}[Y]/(Y-1)$ and want to lift it to $\mathbb{Q}[Y]$, however, I get an error:
sage: D.<Y> = QQ[]
sage: B = matrix(D, [[Y, 0]])
sage: Dbar = D.quotient(Y-1)
sage: Bbar = B.change_ring(Dbar)
sage: Bbar.lift()
Traceback (most recent call last):
...
TypeError: unable to convert 1 to a rational
Lifting single elements instead of a matrix works:
sage: Dbar(Y^2).lift()
1
Lifting a matrix from the integers modulo a prime works also:
sage: B = matrix(ZZ, [[7, 0]])
sage: Dbar = ZZ.quotient(5)
sage: Bbar = B.change_ring(Dbar)
sage: Bbar.lift()
[2 0]
So how do I lift the matrix? Building a new matrix by hand und lifting componentwise seems to be an option; however, I think that it is somewhat ugly.Sat, 12 Nov 2016 23:47:52 -0600https://ask.sagemath.org/question/35555/lifting-a-matrix-from-mathbbqyy-1/Answer by slelievre for <p>I have a matrix in $\mathbb{Q}[Y]/(Y-1)$ and want to lift it to $\mathbb{Q}[Y]$, however, I get an error:</p>
<pre><code>sage: D.<Y> = QQ[]
sage: B = matrix(D, [[Y, 0]])
sage: Dbar = D.quotient(Y-1)
sage: Bbar = B.change_ring(Dbar)
sage: Bbar.lift()
Traceback (most recent call last):
...
TypeError: unable to convert 1 to a rational
</code></pre>
<p>Lifting single elements instead of a matrix works:</p>
<pre><code>sage: Dbar(Y^2).lift()
1
</code></pre>
<p>Lifting a matrix from the integers modulo a prime works also:</p>
<pre><code>sage: B = matrix(ZZ, [[7, 0]])
sage: Dbar = ZZ.quotient(5)
sage: Bbar = B.change_ring(Dbar)
sage: Bbar.lift()
[2 0]
</code></pre>
<p>So how do I lift the matrix? Building a new matrix by hand und lifting componentwise seems to be an option; however, I think that it is somewhat ugly.</p>
https://ask.sagemath.org/question/35555/lifting-a-matrix-from-mathbbqyy-1/?answer=35558#post-id-35558This bug boils down to the following more elementary problem.
sage: D.<Y> = QQ[]
sage: Dbar = D.quotient(Y-1)
sage: one = Dbar.one()
sage: one
1
sage: D(one)
Traceback (most recent call last)
...
TypeError: unable to convert 1 to a rational
A workaround for your use case is as follows.
Instead of
sage: Bbar.lift()
use the following
sage: Bbar.apply_map(Dbar.lift)
[1 0]
You can check that it lives in the correct matrix space:
sage: _.parent()
Full MatrixSpace of 1 by 2 dense matrices over Univariate Polynomial Ring in Y over Rational Field
Sun, 13 Nov 2016 07:10:35 -0600https://ask.sagemath.org/question/35555/lifting-a-matrix-from-mathbbqyy-1/?answer=35558#post-id-35558Comment by slelievre for <p>This bug boils down to the following more elementary problem.</p>
<pre><code>sage: D.<Y> = QQ[]
sage: Dbar = D.quotient(Y-1)
sage: one = Dbar.one()
sage: one
1
sage: D(one)
Traceback (most recent call last)
...
TypeError: unable to convert 1 to a rational
</code></pre>
<p>A workaround for your use case is as follows.</p>
<p>Instead of</p>
<pre><code>sage: Bbar.lift()
</code></pre>
<p>use the following</p>
<pre><code>sage: Bbar.apply_map(Dbar.lift)
[1 0]
</code></pre>
<p>You can check that it lives in the correct matrix space:</p>
<pre><code>sage: _.parent()
Full MatrixSpace of 1 by 2 dense matrices over Univariate Polynomial Ring in Y over Rational Field
</code></pre>
https://ask.sagemath.org/question/35555/lifting-a-matrix-from-mathbbqyy-1/?comment=36181#post-id-36181@Clemens Heuberger: not sure, I have searched neither Sage trac nor Sage lists for it.Wed, 04 Jan 2017 12:17:25 -0600https://ask.sagemath.org/question/35555/lifting-a-matrix-from-mathbbqyy-1/?comment=36181#post-id-36181Comment by Clemens Heuberger for <p>This bug boils down to the following more elementary problem.</p>
<pre><code>sage: D.<Y> = QQ[]
sage: Dbar = D.quotient(Y-1)
sage: one = Dbar.one()
sage: one
1
sage: D(one)
Traceback (most recent call last)
...
TypeError: unable to convert 1 to a rational
</code></pre>
<p>A workaround for your use case is as follows.</p>
<p>Instead of</p>
<pre><code>sage: Bbar.lift()
</code></pre>
<p>use the following</p>
<pre><code>sage: Bbar.apply_map(Dbar.lift)
[1 0]
</code></pre>
<p>You can check that it lives in the correct matrix space:</p>
<pre><code>sage: _.parent()
Full MatrixSpace of 1 by 2 dense matrices over Univariate Polynomial Ring in Y over Rational Field
</code></pre>
https://ask.sagemath.org/question/35555/lifting-a-matrix-from-mathbbqyy-1/?comment=36169#post-id-36169Thank you, the work-around works for me. Is the underlying problem a known bug or shall I create a ticket?Wed, 04 Jan 2017 07:40:30 -0600https://ask.sagemath.org/question/35555/lifting-a-matrix-from-mathbbqyy-1/?comment=36169#post-id-36169