#18818: Segmentation fault on computations in AA, exactify()
---------------------------------+------------------------
Reporter: mkoeppe | Owner:
Type: defect | Status: new
Priority: major | Milestone: sage-6.8
Component: number fields | Resolution:
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
---------------------------------+------------------------
Old description:
> Basic arithmetic with AA can lead to enormous expression trees, which
> easily leads to recursion depth errors and excessive memory use.
>
> {{{
> x = 3*AA(sqrt(2))/200
> moves = [ 1/60, 3*AA(sqrt(2))/200, -AA(sqrt(3))/1000 ]
> for i in xrange(1000000): x = x + moves[randint(0, len(moves)-1)];
> print x
> 12064.933787495?
> x.exactify()
> /Users/mkoeppe/bin/sage: line 134: 41236 Segmentation fault: 11
> "$SAGE_ROOT/src/bin/sage" "$@"
> }}}
>
> (I mentioned this to some developers during the Sage Days in Davis in
> 2013, but didn't follow up on it.)
>
> might be related to #16222
New description:
Basic arithmetic with AA can lead to enormous expression trees, which
easily leads to recursion depth errors and excessive memory use.
{{{
x = 3*AA(sqrt(2))/200
moves = [ 1/60, 3*AA(sqrt(2))/200, -AA(sqrt(3))/1000 ]
for i in xrange(1000000): x = x + moves[randint(0, len(moves)-1)];
print x
12064.933787495?
x.exactify()
/Users/mkoeppe/bin/sage: line 134: 41236 Segmentation fault: 11
"$SAGE_ROOT/src/bin/sage" "$@"
}}}
(I mentioned this to some developers during the Sage Days in Davis in
2013, but didn't follow up on it.)
might be related to #16222. See also the task ticket #18333.
--
Comment (by vdelecroix):
It might be subtle to detect these kinds of things. If you are adding a
lot of numbers that belong to a common number field you would better use
this number field. Possibly using the ready made function
{{{
sage: from sage.rings.qqbar import number_field_elements_from_algebraics
sage: number_field_elements_from_algebraics([AA(2).sqrt(), AA(3).sqrt()])
(Number Field in a with defining polynomial y^4 - 4*y^2 + 1,
[-a^3 + 3*a, -a^2 + 2],
Ring morphism:
From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
To: Algebraic Real Field
Defn: a |--> 0.5176380902050415?)
}}}
The ticket #19955 should definitely handle it. However in such case, with
#20074 and a little extra help it already "works"
{{{
sage: sqrt2 = AA(2).sqrt()
sage: sqrt3 = AA(3).sqrt()
sage: (sqrt2 * sqrt3).exactify()
sage: moves = [ 1/60, 3*sqrt2/200, -sqrt3/1000 ]
... # then same code
}}}
But this current "solution" makes the summation much much slower since
some checks are made to see whether the addition could remain in a given
number field.
--
Ticket URL: <http://trac.sagemath.org/ticket/18818#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.