#10304: PolynomialRing_field.lagrange_polynomial doesn't always return a
polynomial
------------------------+---------------------------------------------------
Reporter: mguaypaq | Owner: mguaypaq
Type: defect | Status: new
Priority: major | Milestone: sage-4.6.1
Component: algebra | Keywords: polynomial ring, lagrange polynomial
Author: | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
------------------------+---------------------------------------------------
The function {{{PolynomialRing_field.lagrange_polynomial}}} sometimes
returns an element of the coefficient ring or even a python int instead of
an element of the polynomial ring. This can lead to problems if the caller
was expecting a polynomial.
{{{
sage: R, t = FractionField(QQ['t']).objgen(); R.rename('R')
sage: S, x = R['x'].objgen(); S.rename('S')
sage: S.lagrange_polynomial([(2, 3 * t), (4, t + 1)]).parent()
S
sage: S.lagrange_polynomial([(2, 3 * t)]).parent()
R
sage: type(S.lagrange_polynomial([]))
<type 'int'>
}}}
The return value is a python int if the list of points was empty, an
element of the base ring if the list of points had one point, and an
element of the polynomial ring if the list of points had more than one
point.
There are similar problems with the base case for the
{{{algorithm='neville'}}} version:
{{{
sage: S.lagrange_polynomial([(2, 3 * t), (4, t + 1)], algorithm='neville')
[t + 1, (-t + 1/2)*x + 5*t - 1]
sage: [poly.parent() for poly in _]
[R, S]
sage: S.lagrange_polynomial([(2, 3 * t)], algorithm='neville')
[3*t]
sage: [poly.parent() for poly in _]
[R]
sage: S.lagrange_polynomial([], algorithm='neville')
0
sage: type(_)
<type 'int'>
}}}
Note that in this case, the return value is not even a list when the list
of points was empty.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10304>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.