#18282: Improve the default evaluation method for univariate polynomials
-------------------------------------+-------------------------------------
Reporter: mmezzarobba | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-6.7
Component: symbolics | Resolution:
Keywords: | Merged in:
Authors: Marc Mezzarobba | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/mmezzarobba/wip/pol_of_symb | 4fdccb24c57c1886aa8849bb1f8e6fe8c4cae1ea
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Description changed by mmezzarobba:
Old description:
> Evaluating of a polynomial (from a polynomial ring) on an element of `SR`
> calls a generic implementation of Horner evaluation, so that the result
> is in (a kind of) Horner form:
> {{{
> sage: pol = QQ['x'](range(10))
> sage: pol(x)
> ((((((((9*x + 8)*x + 7)*x + 6)*x + 5)*x + 4)*x + 3)*x + 2)*x + 1)*x
> }}}
> This is probably not what users expect. Additionally, the conversion
> could be much more efficient.
New description:
Simplify `Polynomial.__call__()`, fix the following issues (note that in
calls of the form `p(x,y,...)`, `x` is the ''outermost'' variable), and
add a few tests.
{{{
sage: Pol_x.<x> = QQ[]
sage: Pol_xy.<y> = Pol_x[]
sage: pol = 1000*x^2*y^2 + 100*y + 10*x + 1
sage: pol(y, 0)
1000*x^2*y^2 + 100*y + 10*x + 1
}}}
{{{
sage: pol(y, 0)
1000*x^2*y^2 + 100*y + 10*x + 1
}}}
{{{
sage: pol(~y, 0) # not the same bug as above
((10*x + 1)*y^2 + 100*y + 1000*x^2)/y^2
}}}
{{{
sage: pol(x, y, x=1)
1000*y^2 + 10*y + 101
}}}
{{{
sage: zero = Pol_xy(0)
sage: zero(1).parent()
Integer Ring
}}}
{{{
sage: zero = QQ['x'](0)
sage: a = matrix(ZZ, [[1]])
sage: zero(a).parent() # should be over QQ
Full MatrixSpace of 1 by 1 dense matrices over Integer Ring
}}}
{{{
sage: zero = GF(2)['x'](0)
sage: zero(1.).parent() # should raise an error
Real Field with 53 bits of precision
}}}
{{{
sage: pol(y=x, x=1)
1111
}}}
{{{
sage: pol = QQ['x'](range(10))
sage: pol(x) # technically not a bug, but should be expanded
((((((((9*x + 8)*x + 7)*x + 6)*x + 5)*x + 4)*x + 3)*x + 2)*x + 1)*x
}}}
Also implement a method to compute the Horner form of a polynomial
expression, in order not to lose the “feature” illustrated in the last
example.
--
--
Ticket URL: <http://trac.sagemath.org/ticket/18282#comment:3>
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 http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.