#13720: Scale legendre_P to [a,b]
------------------------------------+---------------------------------------
Reporter: mjo | Owner: burcin
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-5.11
Component: symbolics | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers: Francis Clarke,
Karl-Dieter Crisman
Authors: Michael Orlitzky | Merged in:
Dependencies: | Stopgaps:
------------------------------------+---------------------------------------
Comment (by mjo):
When n=0, I try to return unity from the same ring as the variable:
{{{
if n == 0:
# Easy base case, save time. Attempt to return a value in the
# same field/ring as x.
try:
return x.parent()(1)
except AttributeError:
# In case something without a parent was given for x.
return 1
}}}
The exceptional case is just there as a failsafe, and it would probably
give a python int. I guess ZZ(1) is better, so I've changed it.
If `n` is a python int, we're happy. Early in the function we check that
`n` can be coerced into `ZZ`. Then later,
{{{
# Ensure that (2**n) is an element of ZZ. This is used later --
# we can divide finite field elements by integers but we can't
# multiply them by rationals at the moment.
n = ZZ(n)
}}}
For speed, the current implementation has,
{{{
sage: timeit('legendre_P(100,x)')
5 loops, best of 3: 57.1 ms per loop
}}}
The posted patch has,
{{{
sage: timeit('legendre_P(100,x)')
5 loops, best of 3: 47.3 ms per loop
}}}
So, even for the unscaled version it's an improvement. There's a slowdown
for the scaled version, of course:
{{{
sage: timeit('legendre_P(100,x,-5,10)')
5 loops, best of 3: 70.4 ms per loop
}}}
But it's still very fast.
You're right about the reference, I must have typo'd it. It's fixed, and
I've added a REFERENCES section to the docs.
The new patch is up, I forgot to check the box, so use the one with the
"2" at the end.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13720#comment:11>
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/groups/opt_out.