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.Sun, 23 Oct 2016 14:21:29 -0500Basic question about annihilatorhttps://ask.sagemath.org/question/35227/basic-question-about-annihilator/I want to compute the intersection of a plane r spanned by two vectors and another plane s defined by its implicit equation.
I thought the following would work:
var('x0,x1,x2')
r0 = vector(QQ,[3,1,-2])
r1 = vector(QQ,[1,-5,3])
r = span([r0,r1])
s = 2*x0 - 3*x1 - 4*x2 == 0
r.annihilator([vector([2,-3,-4])])
But instead I am greeted with an error message saying that `AttributeError: 'sage.rings.rational.Rational' object has no attribute '_vector_'`.
What am I doing wrong?Sat, 22 Oct 2016 11:09:47 -0500https://ask.sagemath.org/question/35227/basic-question-about-annihilator/Answer by tmonteil for <p>I want to compute the intersection of a plane r spanned by two vectors and another plane s defined by its implicit equation.
I thought the following would work:</p>
<pre><code>var('x0,x1,x2')
r0 = vector(QQ,[3,1,-2])
r1 = vector(QQ,[1,-5,3])
r = span([r0,r1])
s = 2*x0 - 3*x1 - 4*x2 == 0
r.annihilator([vector([2,-3,-4])])
</code></pre>
<p>But instead I am greeted with an error message saying that <code>AttributeError: 'sage.rings.rational.Rational' object has no attribute '_vector_'</code>.</p>
<p>What am I doing wrong?</p>
https://ask.sagemath.org/question/35227/basic-question-about-annihilator/?answer=35239#post-id-35239`r` is correctly defined. For `s`, i would just do:
sage: s = matrix(QQ,[2,-3,-4]).right_kernel()
sage: s
Vector space of degree 3 and dimension 2 over Rational Field
Basis matrix:
[ 1 0 1/2]
[ 0 1 -3/4]
Then you can do:
sage: s.intersection(r)
Vector space of degree 3 and dimension 1 over Rational Field
Basis matrix:
[ 1 15 -43/4]
And check
sage: r.intersection(s)
Vector space of degree 3 and dimension 1 over Rational Field
Basis matrix:
[ 1 15 -43/4]
sage: b = r.intersection(s).basis()[0] ; b
(1, 15, -43/4)
sage: b in r
True
sage: b in s
True
As a general rule, unlike say complex analysis, Sage already offers precise objects to work with linear spaces, polynomials, combinatorics, so that you should avoid the use of fuzzy symbolic things.Sun, 23 Oct 2016 14:21:29 -0500https://ask.sagemath.org/question/35227/basic-question-about-annihilator/?answer=35239#post-id-35239Answer by kcrisman for <p>I want to compute the intersection of a plane r spanned by two vectors and another plane s defined by its implicit equation.
I thought the following would work:</p>
<pre><code>var('x0,x1,x2')
r0 = vector(QQ,[3,1,-2])
r1 = vector(QQ,[1,-5,3])
r = span([r0,r1])
s = 2*x0 - 3*x1 - 4*x2 == 0
r.annihilator([vector([2,-3,-4])])
</code></pre>
<p>But instead I am greeted with an error message saying that <code>AttributeError: 'sage.rings.rational.Rational' object has no attribute '_vector_'</code>.</p>
<p>What am I doing wrong?</p>
https://ask.sagemath.org/question/35227/basic-question-about-annihilator/?answer=35228#post-id-35228If you use the syntax in `r.annihilator?` then it makes it one step further:
sage: r.annihilator([2,-3,-4])
...
AttributeError: 'FreeModule_submodule_field_with_category' object has no attribute 'from_vector'
But I think you meant one vector, not three rationals, so that isn't helpful. I have opened [Trac 21742](https://trac.sagemath.org/ticket/21742) for this; I suspect this simply isn't a case where this was intended to be used.Sat, 22 Oct 2016 12:13:00 -0500https://ask.sagemath.org/question/35227/basic-question-about-annihilator/?answer=35228#post-id-35228Comment by Jsevillamol for <p>If you use the syntax in <code>r.annihilator?</code> then it makes it one step further:</p>
<pre><code>sage: r.annihilator([2,-3,-4])
...
AttributeError: 'FreeModule_submodule_field_with_category' object has no attribute 'from_vector'
</code></pre>
<p>But I think you meant one vector, not three rationals, so that isn't helpful. I have opened <a href="https://trac.sagemath.org/ticket/21742">Trac 21742</a> for this; I suspect this simply isn't a case where this was intended to be used.</p>
https://ask.sagemath.org/question/35227/basic-question-about-annihilator/?comment=35229#post-id-35229My intention was to filter the elements of r such that they satisfied s's equation.
That is, the elements of r which map to 0 when you do the dot vector with [2,-3,-4].
What would be the canonical way of doing this?Sat, 22 Oct 2016 13:47:44 -0500https://ask.sagemath.org/question/35227/basic-question-about-annihilator/?comment=35229#post-id-35229